aboutsummaryrefslogtreecommitdiff
path: root/include/platform.h
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-05-19 13:18:45 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-05-19 13:18:45 +0200
commit5a49d284a6a9f6cf2076f23561f95aebdfd44592 (patch)
tree3e51b2c326a9c7d3b18f3d04c91b6af9e5c0621a /include/platform.h
parent167cd709df06fb0f7aa346a32133d54ed3ae6c48 (diff)
downloadbusybox-w32-5a49d284a6a9f6cf2076f23561f95aebdfd44592.tar.gz
busybox-w32-5a49d284a6a9f6cf2076f23561f95aebdfd44592.tar.bz2
busybox-w32-5a49d284a6a9f6cf2076f23561f95aebdfd44592.zip
add platform tweaks
login: consider platforms having no domainname field in the utsname struct include/platform.h: define IUCLC to 0 on platforms where it is not defined Signed-off-by: Luca Favatella <slackydeb@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'include/platform.h')
-rw-r--r--include/platform.h166
1 files changed, 87 insertions, 79 deletions
diff --git a/include/platform.h b/include/platform.h
index 317349fed..e2136a2ea 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -19,7 +19,7 @@
19/* __restrict is known in EGCS 1.2 and above. */ 19/* __restrict is known in EGCS 1.2 and above. */
20#if !__GNUC_PREREQ(2,92) 20#if !__GNUC_PREREQ(2,92)
21# ifndef __restrict 21# ifndef __restrict
22# define __restrict /* Ignore */ 22# define __restrict
23# endif 23# endif
24#endif 24#endif
25 25
@@ -61,14 +61,14 @@
61# define DEPRECATED __attribute__ ((__deprecated__)) 61# define DEPRECATED __attribute__ ((__deprecated__))
62# define UNUSED_PARAM_RESULT __attribute__ ((warn_unused_result)) 62# define UNUSED_PARAM_RESULT __attribute__ ((warn_unused_result))
63# else 63# else
64# define DEPRECATED /* n/a */ 64# define DEPRECATED
65# define UNUSED_PARAM_RESULT /* n/a */ 65# define UNUSED_PARAM_RESULT
66# endif 66# endif
67#else 67#else
68# define ALWAYS_INLINE inline /* n/a */ 68# define ALWAYS_INLINE inline
69# define NOINLINE /* n/a */ 69# define NOINLINE
70# define DEPRECATED /* n/a */ 70# define DEPRECATED
71# define UNUSED_PARAM_RESULT /* n/a */ 71# define UNUSED_PARAM_RESULT
72#endif 72#endif
73 73
74/* -fwhole-program makes all symbols local. The attribute externally_visible 74/* -fwhole-program makes all symbols local. The attribute externally_visible
@@ -144,19 +144,19 @@
144 144
145/* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */ 145/* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */
146#if BB_BIG_ENDIAN 146#if BB_BIG_ENDIAN
147#define SWAP_BE16(x) (x) 147# define SWAP_BE16(x) (x)
148#define SWAP_BE32(x) (x) 148# define SWAP_BE32(x) (x)
149#define SWAP_BE64(x) (x) 149# define SWAP_BE64(x) (x)
150#define SWAP_LE16(x) bswap_16(x) 150# define SWAP_LE16(x) bswap_16(x)
151#define SWAP_LE32(x) bswap_32(x) 151# define SWAP_LE32(x) bswap_32(x)
152#define SWAP_LE64(x) bswap_64(x) 152# define SWAP_LE64(x) bswap_64(x)
153#else 153#else
154#define SWAP_BE16(x) bswap_16(x) 154# define SWAP_BE16(x) bswap_16(x)
155#define SWAP_BE32(x) bswap_32(x) 155# define SWAP_BE32(x) bswap_32(x)
156#define SWAP_BE64(x) bswap_64(x) 156# define SWAP_BE64(x) bswap_64(x)
157#define SWAP_LE16(x) (x) 157# define SWAP_LE16(x) (x)
158#define SWAP_LE32(x) (x) 158# define SWAP_LE32(x) (x)
159#define SWAP_LE64(x) (x) 159# define SWAP_LE64(x) (x)
160#endif 160#endif
161 161
162/* ---- Unaligned access ------------------------------------ */ 162/* ---- Unaligned access ------------------------------------ */
@@ -165,15 +165,15 @@
165 * a lvalue. This makes it more likely to not swap them by mistake 165 * a lvalue. This makes it more likely to not swap them by mistake
166 */ 166 */
167#if defined(i386) || defined(__x86_64__) 167#if defined(i386) || defined(__x86_64__)
168#define move_from_unaligned16(v, u16p) ((v) = *(uint16_t*)(u16p)) 168# define move_from_unaligned16(v, u16p) ((v) = *(uint16_t*)(u16p))
169#define move_from_unaligned32(v, u32p) ((v) = *(uint32_t*)(u32p)) 169# define move_from_unaligned32(v, u32p) ((v) = *(uint32_t*)(u32p))
170#define move_to_unaligned32(u32p, v) (*(uint32_t*)(u32p) = (v)) 170# define move_to_unaligned32(u32p, v) (*(uint32_t*)(u32p) = (v))
171/* #elif ... - add your favorite arch today! */ 171/* #elif ... - add your favorite arch today! */
172#else 172#else
173/* performs reasonably well (gcc usually inlines memcpy here) */ 173/* performs reasonably well (gcc usually inlines memcpy here) */
174#define move_from_unaligned16(v, u16p) (memcpy(&(v), (u16p), 2)) 174# define move_from_unaligned16(v, u16p) (memcpy(&(v), (u16p), 2))
175#define move_from_unaligned32(v, u32p) (memcpy(&(v), (u32p), 4)) 175# define move_from_unaligned32(v, u32p) (memcpy(&(v), (u32p), 4))
176#define move_to_unaligned32(u32p, v) do { \ 176# define move_to_unaligned32(u32p, v) do { \
177 uint32_t __t = (v); \ 177 uint32_t __t = (v); \
178 memcpy((u32p), &__t, 4); \ 178 memcpy((u32p), &__t, 4); \
179} while (0) 179} while (0)
@@ -225,21 +225,21 @@ __extension__ typedef unsigned long long __u64;
225 225
226#if defined __GLIBC__ || defined __UCLIBC__ \ 226#if defined __GLIBC__ || defined __UCLIBC__ \
227 || defined __dietlibc__ || defined _NEWLIB_VERSION 227 || defined __dietlibc__ || defined _NEWLIB_VERSION
228#include <features.h> 228# include <features.h>
229#define HAVE_FEATURES_H 229# define HAVE_FEATURES_H
230#include <stdint.h> 230# include <stdint.h>
231#define HAVE_STDINT_H 231# define HAVE_STDINT_H
232#elif !defined __APPLE__ 232#elif !defined __APPLE__
233/* Largest integral types. */ 233/* Largest integral types. */
234#if __BIG_ENDIAN__ 234# if __BIG_ENDIAN__
235typedef long intmax_t; 235typedef long intmax_t;
236typedef unsigned long uintmax_t; 236typedef unsigned long uintmax_t;
237#else 237# else
238__extension__ 238__extension__
239typedef long long intmax_t; 239typedef long long intmax_t;
240__extension__ 240__extension__
241typedef unsigned long long uintmax_t; 241typedef unsigned long long uintmax_t;
242#endif 242# endif
243#endif 243#endif
244 244
245/* Size-saving "small" ints (arch-dependent) */ 245/* Size-saving "small" ints (arch-dependent) */
@@ -256,20 +256,20 @@ typedef unsigned smalluint;
256/* ISO C Standard: 7.16 Boolean type and values <stdbool.h> */ 256/* ISO C Standard: 7.16 Boolean type and values <stdbool.h> */
257#if (defined __digital__ && defined __unix__) 257#if (defined __digital__ && defined __unix__)
258/* old system without (proper) C99 support */ 258/* old system without (proper) C99 support */
259#define bool smalluint 259# define bool smalluint
260#else 260#else
261/* modern system, so use it */ 261/* modern system, so use it */
262#include <stdbool.h> 262# include <stdbool.h>
263#endif 263#endif
264 264
265/* Try to defeat gcc's alignment of "char message[]"-like data */ 265/* Try to defeat gcc's alignment of "char message[]"-like data */
266#if 1 /* if needed: !defined(arch1) && !defined(arch2) */ 266#if 1 /* if needed: !defined(arch1) && !defined(arch2) */
267#define ALIGN1 __attribute__((aligned(1))) 267# define ALIGN1 __attribute__((aligned(1)))
268#define ALIGN2 __attribute__((aligned(2))) 268# define ALIGN2 __attribute__((aligned(2)))
269#else 269#else
270/* Arches which MUST have 2 or 4 byte alignment for everything are here */ 270/* Arches which MUST have 2 or 4 byte alignment for everything are here */
271#define ALIGN1 271# define ALIGN1
272#define ALIGN2 272# define ALIGN2
273#endif 273#endif
274 274
275 275
@@ -281,13 +281,13 @@ typedef unsigned smalluint;
281#if ENABLE_NOMMU || \ 281#if ENABLE_NOMMU || \
282 (defined __UCLIBC__ && __UCLIBC_MAJOR__ >= 0 && __UCLIBC_MINOR__ >= 9 && \ 282 (defined __UCLIBC__ && __UCLIBC_MAJOR__ >= 0 && __UCLIBC_MINOR__ >= 9 && \
283 __UCLIBC_SUBLEVEL__ > 28 && !defined __ARCH_USE_MMU__) 283 __UCLIBC_SUBLEVEL__ > 28 && !defined __ARCH_USE_MMU__)
284#define BB_MMU 0 284# define BB_MMU 0
285#define USE_FOR_NOMMU(...) __VA_ARGS__ 285# define USE_FOR_NOMMU(...) __VA_ARGS__
286#define USE_FOR_MMU(...) 286# define USE_FOR_MMU(...)
287#else 287#else
288#define BB_MMU 1 288# define BB_MMU 1
289#define USE_FOR_NOMMU(...) 289# define USE_FOR_NOMMU(...)
290#define USE_FOR_MMU(...) __VA_ARGS__ 290# define USE_FOR_MMU(...) __VA_ARGS__
291#endif 291#endif
292 292
293/* Platforms that haven't got dprintf need to implement fdprintf() in 293/* Platforms that haven't got dprintf need to implement fdprintf() in
@@ -297,7 +297,7 @@ typedef unsigned smalluint;
297/* Needed for: glibc */ 297/* Needed for: glibc */
298/* Not needed for: dietlibc */ 298/* Not needed for: dietlibc */
299/* Others: ?? (add as needed) */ 299/* Others: ?? (add as needed) */
300#define fdprintf dprintf 300# define fdprintf dprintf
301#endif 301#endif
302 302
303#if defined(__dietlibc__) 303#if defined(__dietlibc__)
@@ -323,7 +323,6 @@ static ALWAYS_INLINE char* strchrnul(const char *s, char c)
323# define PRIu32 "u" 323# define PRIu32 "u"
324/* use legacy setpgrp(pid_t,pid_t) for now. move to platform.c */ 324/* use legacy setpgrp(pid_t,pid_t) for now. move to platform.c */
325# define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me,__me); } while (0) 325# define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me,__me); } while (0)
326
327# if !defined ADJ_OFFSET_SINGLESHOT && defined MOD_CLKA && defined MOD_OFFSET 326# if !defined ADJ_OFFSET_SINGLESHOT && defined MOD_CLKA && defined MOD_OFFSET
328# define ADJ_OFFSET_SINGLESHOT (MOD_CLKA | MOD_OFFSET) 327# define ADJ_OFFSET_SINGLESHOT (MOD_CLKA | MOD_OFFSET)
329# endif 328# endif
@@ -344,44 +343,53 @@ static ALWAYS_INLINE char* strchrnul(const char *s, char c)
344#endif 343#endif
345 344
346#if defined(__linux__) 345#if defined(__linux__)
347#include <sys/mount.h> 346# include <sys/mount.h>
348/* Make sure we have all the new mount flags we actually try to use. */ 347/* Make sure we have all the new mount flags we actually try to use. */
349#ifndef MS_BIND 348# ifndef MS_BIND
350#define MS_BIND (1<<12) 349# define MS_BIND (1 << 12)
351#endif 350# endif
352#ifndef MS_MOVE 351# ifndef MS_MOVE
353#define MS_MOVE (1<<13) 352# define MS_MOVE (1 << 13)
354#endif 353# endif
355#ifndef MS_RECURSIVE 354# ifndef MS_RECURSIVE
356#define MS_RECURSIVE (1<<14) 355# define MS_RECURSIVE (1 << 14)
357#endif 356# endif
358#ifndef MS_SILENT 357# ifndef MS_SILENT
359#define MS_SILENT (1<<15) 358# define MS_SILENT (1 << 15)
360#endif 359# endif
361
362/* The shared subtree stuff, which went in around 2.6.15. */ 360/* The shared subtree stuff, which went in around 2.6.15. */
363#ifndef MS_UNBINDABLE 361# ifndef MS_UNBINDABLE
364#define MS_UNBINDABLE (1<<17) 362# define MS_UNBINDABLE (1 << 17)
365#endif 363# endif
366#ifndef MS_PRIVATE 364# ifndef MS_PRIVATE
367#define MS_PRIVATE (1<<18) 365# define MS_PRIVATE (1 << 18)
368#endif 366# endif
369#ifndef MS_SLAVE 367# ifndef MS_SLAVE
370#define MS_SLAVE (1<<19) 368# define MS_SLAVE (1 << 19)
371#endif 369# endif
372#ifndef MS_SHARED 370# ifndef MS_SHARED
373#define MS_SHARED (1<<20) 371# define MS_SHARED (1 << 20)
374#endif 372# endif
375#ifndef MS_RELATIME 373# ifndef MS_RELATIME
376#define MS_RELATIME (1 << 21) 374# define MS_RELATIME (1 << 21)
377#endif 375# endif
378 376
379#if !defined(BLKSSZGET) 377# if !defined(BLKSSZGET)
380#define BLKSSZGET _IO(0x12, 104) 378# define BLKSSZGET _IO(0x12, 104)
379# endif
380# if !defined(BLKGETSIZE64)
381# define BLKGETSIZE64 _IOR(0x12,114,size_t)
382# endif
381#endif 383#endif
382#if !defined(BLKGETSIZE64) 384
383#define BLKGETSIZE64 _IOR(0x12,114,size_t) 385/* The field domainname of struct utsname is Linux specific. */
386#if !defined(__linux__)
387# define HAVE_NO_UTSNAME_DOMAINNAME
384#endif 388#endif
389
390/* If this system doesn't have IUCLC bit in struct termios::c_iflag... */
391#ifndef IUCLC
392# define IUCLC 0
385#endif 393#endif
386 394
387#endif 395#endif