OSDN Git Service

Use compiler built-in macros to determine if argument parsing can use double or float...
authorRob Landley <rob@landley.net>
Tue, 6 May 2014 11:14:20 +0000 (06:14 -0500)
committerRob Landley <rob@landley.net>
Tue, 6 May 2014 11:14:20 +0000 (06:14 -0500)
lib/pending.h
lib/portability.h

index 67605c0..5e3b309 100644 (file)
@@ -1,13 +1,5 @@
 // pending.h - header for pending.c
 
-// Unfortunately, sizeof() doesn't work in a preprocessor test.  TODO.
-
-//#if sizeof(double) <= sizeof(long)
-//typedef double FLOAT;
-//#else
-typedef float FLOAT;
-//#endif
-
 // password.c
 #define MAX_SALT_LEN  20 //3 for id, 16 for key, 1 for '\0'
 #define SYS_FIRST_ID  100
index 099f321..1d540ac 100644 (file)
@@ -148,7 +148,8 @@ int clearenv(void);
 #define SWAP_LE64(x) (x)
 #endif
 
-#if defined(__APPLE__) || defined(__ANDROID__) || (defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 10)
+#if defined(__APPLE__) || defined(__ANDROID__) \
+    || (defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 10)
 ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
 ssize_t getline(char **lineptr, size_t *n, FILE *stream);
 #endif
@@ -163,3 +164,11 @@ ssize_t getline(char **lineptr, size_t *n, FILE *stream);
 #ifndef O_NOFOLLOW
 #define O_NOFOLLOW 0
 #endif
+
+#if defined(__SIZEOF_DOUBLE__) && defined(__SIZEOF_LONG__) \
+    && __SIZEOF_DOUBLE__ <= __SIZEOF_LONG__
+typedef double FLOAT;
+#else
+typedef float FLOAT;
+#endif
+