13d0407baSopenharmony_ci/* 23d0407baSopenharmony_ci * Copyright (c) 2022 FuZhou Lockzhiner Electronic Co., Ltd. All rights reserved. 33d0407baSopenharmony_ci * Copyright (c) 1991, 1993 43d0407baSopenharmony_ci * The Regents of the University of California. All rights reserved. 53d0407baSopenharmony_ci * 63d0407baSopenharmony_ci * This code is derived from software contributed to Berkeley by 73d0407baSopenharmony_ci * Berkeley Software Design, Inc. 83d0407baSopenharmony_ci * 93d0407baSopenharmony_ci * Redistribution and use in source and binary forms, with or without 103d0407baSopenharmony_ci * modification, are permitted provided that the following conditions 113d0407baSopenharmony_ci * are met: 123d0407baSopenharmony_ci * 1. Redistributions of source code must retain the above copyright 133d0407baSopenharmony_ci * notice, this list of conditions and the following disclaimer. 143d0407baSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 153d0407baSopenharmony_ci * notice, this list of conditions and the following disclaimer in the 163d0407baSopenharmony_ci * documentation and/or other materials provided with the distribution. 173d0407baSopenharmony_ci * 4. Neither the name of the University nor the names of its contributors 183d0407baSopenharmony_ci * may be used to endorse or promote products derived from this software 193d0407baSopenharmony_ci * without specific prior written permission. 203d0407baSopenharmony_ci * 213d0407baSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 223d0407baSopenharmony_ci * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 233d0407baSopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 243d0407baSopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 253d0407baSopenharmony_ci * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 263d0407baSopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 273d0407baSopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 283d0407baSopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 293d0407baSopenharmony_ci * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 303d0407baSopenharmony_ci * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 313d0407baSopenharmony_ci * SUCH DAMAGE. 323d0407baSopenharmony_ci * 333d0407baSopenharmony_ci */ 343d0407baSopenharmony_ci 353d0407baSopenharmony_ci#ifndef _SYS_DEFS_H 363d0407baSopenharmony_ci#define _SYS_DEFS_H 373d0407baSopenharmony_ci 383d0407baSopenharmony_ci#include <stddef.h> 393d0407baSopenharmony_ci#include <stdint.h> 403d0407baSopenharmony_ci 413d0407baSopenharmony_ci#ifndef __DEQUALIFY 423d0407baSopenharmony_ci#define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var)) 433d0407baSopenharmony_ci#endif 443d0407baSopenharmony_ci 453d0407baSopenharmony_ci#ifndef offsetof 463d0407baSopenharmony_ci#define offsetof(type, field) \ 473d0407baSopenharmony_ci ((size_t)(uintptr_t)((const volatile void *)&((type *)0)->field)) 483d0407baSopenharmony_ci#endif 493d0407baSopenharmony_ci 503d0407baSopenharmony_ci#ifndef __offsetof 513d0407baSopenharmony_ci#define __offsetof(type, field) offsetof(type, field) 523d0407baSopenharmony_ci#endif 533d0407baSopenharmony_ci 543d0407baSopenharmony_ci#ifndef __containerof 553d0407baSopenharmony_ci#define __containerof(ptr, type, field) \ 563d0407baSopenharmony_ci __DEQUALIFY(type *, (const volatile char *)(ptr) - offsetof(type, field)) 573d0407baSopenharmony_ci#endif 583d0407baSopenharmony_ci 593d0407baSopenharmony_ci#ifndef container_of 603d0407baSopenharmony_ci#define container_of(ptr, type, field) __containerof(ptr, type, field) 613d0407baSopenharmony_ci#endif 623d0407baSopenharmony_ci 633d0407baSopenharmony_ci/* 643d0407baSopenharmony_ci * Definitions for byte order, according to byte significance from low 653d0407baSopenharmony_ci * address to high. 663d0407baSopenharmony_ci */ 673d0407baSopenharmony_ci#ifndef _LITTLE_ENDIAN 683d0407baSopenharmony_ci#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ 693d0407baSopenharmony_ci#endif 703d0407baSopenharmony_ci#ifndef _BIG_ENDIAN 713d0407baSopenharmony_ci#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ 723d0407baSopenharmony_ci#endif 733d0407baSopenharmony_ci 743d0407baSopenharmony_ci#ifndef LITTLE_ENDIAN 753d0407baSopenharmony_ci#define LITTLE_ENDIAN _LITTLE_ENDIAN 763d0407baSopenharmony_ci#endif 773d0407baSopenharmony_ci#ifndef BIG_ENDIAN 783d0407baSopenharmony_ci#define BIG_ENDIAN _BIG_ENDIAN 793d0407baSopenharmony_ci#endif 803d0407baSopenharmony_ci 813d0407baSopenharmony_ci#ifndef _BYTE_ORDER 823d0407baSopenharmony_ci#define _BYTE_ORDER _LITTLE_ENDIAN 833d0407baSopenharmony_ci#endif 843d0407baSopenharmony_ci#ifndef BYTE_ORDER 853d0407baSopenharmony_ci#define BYTE_ORDER _BYTE_ORDER 863d0407baSopenharmony_ci#endif 873d0407baSopenharmony_ci 883d0407baSopenharmony_ci#endif /* _SYS_DEFS_H */ 89