X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/b226f5e54a60dc81db17b1260381d7dbfea3cdf1..0a7de7458d150b5d4dffc935ba399be265ef0a1a:/bsd/sys/linker_set.h diff --git a/bsd/sys/linker_set.h b/bsd/sys/linker_set.h index 4ebdcec61..820bc2e36 100644 --- a/bsd/sys/linker_set.h +++ b/bsd/sys/linker_set.h @@ -2,7 +2,7 @@ * Copyright (c) 2006-2008 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in @@ -11,10 +11,10 @@ * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. - * + * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -22,7 +22,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ * * @@ -64,7 +64,7 @@ * For Mach-O, this is done by constructing a separate segment inside the * __DATA section for each set. The contents of this segment are an array * of pointers to the objects in the set. - * + * * Note that due to limitations of the Mach-O format, there cannot * be more than 255 sections in a segment, so linker set usage should be * conserved. Set names may not exceed 16 characters. @@ -100,28 +100,28 @@ struct linker_set_entry { #ifdef __LS_VA_STRCONCAT__ # undef __LS_VA_STRCONCAT__ #endif -#define __LS_VA_STRINGIFY(_x...) #_x -#define __LS_VA_STRCONCAT(_x,_y) __LS_VA_STRINGIFY(_x,_y) -#define __LINKER_MAKE_SET(_set, _sym) \ - /*__unused*/ /*static*/ const struct linker_set_entry /*const*/ __set_##_set##_sym_##_sym \ +#define __LS_VA_STRINGIFY(_x ...) #_x +#define __LS_VA_STRCONCAT(_x, _y) __LS_VA_STRINGIFY(_x,_y) +#define __LINKER_MAKE_SET(_set, _sym) \ + /*__unused*/ /*static*/ const struct linker_set_entry /*const*/ __set_##_set##_sym_##_sym \ __attribute__ ((section(__LS_VA_STRCONCAT(__DATA,_set)),used)) = { (void *)&_sym } /* the line above is very fragile - if your compiler breaks linker sets, - just play around with "static", "const", "used" etc. :-) */ + * just play around with "static", "const", "used" etc. :-) */ /* * Public macros. */ -#define LINKER_SET_ENTRY(_set, _sym) __LINKER_MAKE_SET(_set, _sym) +#define LINKER_SET_ENTRY(_set, _sym) __LINKER_MAKE_SET(_set, _sym) /* * FreeBSD compatibility. */ #ifdef __APPLE_API_OBSOLETE -# define TEXT_SET(_set, _sym) __LINKER_MAKE_SET(_set, _sym) -# define DATA_SET(_set, _sym) __LINKER_MAKE_SET(_set, _sym) -# define BSS_SET(_set, _sym) __LINKER_MAKE_SET(_set, _sym) -# define ABS_SET(_set, _sym) __LINKER_MAKE_SET(_set, _sym) -# define SET_ENTRY(_set, _sym) __LINKER_MAKE_SET(_set, _sym) +# define TEXT_SET(_set, _sym) __LINKER_MAKE_SET(_set, _sym) +# define DATA_SET(_set, _sym) __LINKER_MAKE_SET(_set, _sym) +# define BSS_SET(_set, _sym) __LINKER_MAKE_SET(_set, _sym) +# define ABS_SET(_set, _sym) __LINKER_MAKE_SET(_set, _sym) +# define SET_ENTRY(_set, _sym) __LINKER_MAKE_SET(_set, _sym) #endif /* __APPLE_API_OBSOLETE */ /* @@ -149,22 +149,22 @@ struct linker_set_entry { * LINKER_SET_FOREACH((set_member_type **)_pvar, _cast, _set) * * Example of _cast: For the _pvar "struct sysctl_oid **oidpp", _cast would be - * "struct sysctl_oid **" + * "struct sysctl_oid **" * */ -#define LINKER_SET_OBJECT_BEGIN(_object, _set) __linker_set_object_begin(_object, _set) -#define LINKER_SET_OBJECT_LIMIT(_object, _set) __linker_set_object_limit(_object, _set) +#define LINKER_SET_OBJECT_BEGIN(_object, _set) __linker_set_object_begin(_object, _set) +#define LINKER_SET_OBJECT_LIMIT(_object, _set) __linker_set_object_limit(_object, _set) -#define LINKER_SET_OBJECT_FOREACH(_object, _pvar, _cast, _set) \ - for (_pvar = (_cast) LINKER_SET_OBJECT_BEGIN(_object, _set); \ - _pvar < (_cast) LINKER_SET_OBJECT_LIMIT(_object, _set); \ +#define LINKER_SET_OBJECT_FOREACH(_object, _pvar, _cast, _set) \ + for (_pvar = (_cast) LINKER_SET_OBJECT_BEGIN(_object, _set); \ + _pvar < (_cast) LINKER_SET_OBJECT_LIMIT(_object, _set); \ _pvar++) -#define LINKER_SET_OBJECT_ITEM(_object, _cast, _set, _i) \ +#define LINKER_SET_OBJECT_ITEM(_object, _cast, _set, _i) \ (((_cast)(LINKER_SET_OBJECT_BEGIN(_object, _set)))[_i]) -#define LINKER_SET_FOREACH(_pvar, _cast, _set) \ +#define LINKER_SET_FOREACH(_pvar, _cast, _set) \ LINKER_SET_OBJECT_FOREACH((kernel_mach_header_t *)&_mh_execute_header, _pvar, _cast, _set) /* @@ -178,7 +178,7 @@ struct linker_set_entry { static __inline void ** __linker_set_object_begin(kernel_mach_header_t *_header, const char *_set) - __attribute__((__const__)); +__attribute__((__const__)); static __inline void ** __linker_set_object_begin(kernel_mach_header_t *_header, const char *_set) { @@ -186,12 +186,12 @@ __linker_set_object_begin(kernel_mach_header_t *_header, const char *_set) unsigned long _size; _set_begin = getsectdatafromheader(_header, "__DATA", _set, &_size); - return( (void **) _set_begin ); + return (void **) _set_begin; } static __inline void ** __linker_set_object_limit(kernel_mach_header_t *_header, const char *_set) - __attribute__((__const__)); +__attribute__((__const__)); static __inline void ** __linker_set_object_limit(kernel_mach_header_t *_header, const char *_set) { @@ -199,12 +199,10 @@ __linker_set_object_limit(kernel_mach_header_t *_header, const char *_set) unsigned long _size; _set_begin = getsectdatafromheader(_header, "__DATA", _set, &_size); - - return ((void **) ((uintptr_t) _set_begin + _size)); + + return (void **) ((uintptr_t) _set_begin + _size); } #endif /* !KERNEL || __APPLE_API_PRIVATE */ #endif /* _SYS_LINKER_SET_H_ */ - -