about summary refs log tree commit diff
path: root/pm_config.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'pm_config.in.h')
-rw-r--r--pm_config.in.h167
1 files changed, 101 insertions, 66 deletions
diff --git a/pm_config.in.h b/pm_config.in.h
index 51a7b966..fe8b8008 100644
--- a/pm_config.in.h
+++ b/pm_config.in.h
@@ -15,7 +15,7 @@
 
 **************************************************************************/
 
-#if defined(USG) || defined(SVR4) || defined(VMS) || defined(__SVR4)
+#if defined(USG) || defined(SVR4) || defined(__SVR4)
 #define SYSV
 #endif
 #if !( defined(BSD) || defined(SYSV) || defined(MSDOS) || defined(__amigaos__))
@@ -54,45 +54,29 @@
 #endif
 
 
-/* CONFIGURE: If you have an X11-style rgb color names file, define its
-** path here.  This is used by PPM to parse color names into rgb values.
-** If you don't have such a file, comment this out and use the alternative
-** hex and decimal forms to specify colors (see ppm/pgmtoppm.1 for details).  */
-
-#define RGB_DB_PATH \
-"/usr/share/netpbm/rgb.txt:" \
-"/usr/lib/X11/rgb.txt:" \
-"/usr/share/X11/rgb.txt:" \
-"/usr/X11R6/lib/X11/rgb.txt"
-
 /* CONFIGURE: This is the name of an environment variable that tells
 ** where the color names database is.  If the environment variable isn't
-** set, Netpbm tries the hardcoded defaults set above.
+** set, Netpbm tries the hardcoded defaults per macro 'RGB_DB_PATH'
+** (see below).
 */
 #define RGBENV "RGBDEF"    /* name of env-var */
 
+/* CONFIGURE: There should be an environment variable telling where the color
+** names database (color dictionary) is for Netpbm to use, e.g. to determine
+** what colord name "Salmon" is.  The name of that environment variable is
+** above.  But as some people prefer hardcoded file paths to environment
+** variables, if such environment variable is not set, Netpbm looks for the
+** first existing file in the list which is the value of 'RGB_DB_PATH'.  And
+** if none of those exist (including if the list is empty), Netpbm simply
+** doesn't understand any color names.  Note that Netpbm comes with a color
+** database (lib/rgb.txt in the source tree), but you might choose to have
+** Netpbm use a different one.  See the documentation of ppm_parsecolor()
+** for the format of the color database file.
+*/
+
 #if (defined(SYSV) || defined(__amigaos__))
 
 #include <string.h>
-/* Before Netpbm 9.1, rand and srand were macros for random and
-   srandom here.  This caused a failure on a SunOS 5.6 system, which
-   is SYSV, but has both rand and random declared (with different
-   return types).  The macro caused the prototype for random to be a
-   second prototype for rand.  Before 9.1, Netpbm programs called
-   random() and on a SVID system, that was really a call to rand().
-   We assume all modern systems have rand() itself, so now Netpbm
-   always calls rand() and if we find a platform that doesn't have
-   rand(), we will add something here for that platform.  -Bryan 00.04.26
-#define random rand
-#define srandom(s) srand(s)
-extern void srand();
-extern int rand();
-*/
-/* Before Netpbm 9.15, there were macro definitions of index() and 
-   rindex() here, but there are no longer any invocations of those 
-   functions in Netpbm, except in the VMS-only code, so there's no
-   reason for them.
-*/
 
 #ifndef __SASC
 #ifndef _DCC    /* Amiga DICE Compiler */
@@ -115,15 +99,22 @@ extern int rand();
 #ifdef BSD
 #include <stdlib.h>
 #endif
-#if (defined(SYSV) && !defined(VMS))
+#if defined(SYSV)
 #include <malloc.h>
 #endif
 
-/* CONFIGURE: If your system has the setmode() function, set HAVE_SETMODE.
-** If you do, and also the O_BINARY file mode, pm_init() will set the mode
-** of stdin and stdout to binary for all Netpbm programs.
-** You need this with Cygwin (Windows).
-*/
+/* MSVCRT means we're using the Microsoft Visual C++ runtime library.
+
+   _WIN32, set by the compiler, apparently means the same thing; we see it set
+   in compiles using the Microsoft Visual C++ development environment and also
+   with Mingw, which is the Windows version of the GNU compiler (which brings
+   with it a runtime library which wraps around the Microsoft one).  We don't
+   see it set in Cygwin compiles, which use GNU libraries instead of the
+   Microsoft one.
+
+   There is also _MSC_VER, which is set by MSVC to the version number of the
+   MSVC runtime library and __MINGW32__.
+ */
 
 #ifdef _WIN32
 #define MSVCRT 1
@@ -131,18 +122,42 @@ extern int rand();
 #define MSVCRT 0
 #endif
 
+/* WIN32 is a macro that some older compilers predefine (compilers aren't
+   supposed to because it doesn't start with an underscore, hence the change.
+   Many build systems (project files, etc.) set WIN32 explicitly for
+   backward compatibility.  Netpbm doesn't use it.
+*/
+
+/* CONFIGURE: If your system has the setmode() function, set HAVE_SETMODE.
+** If you do, and also the O_BINARY file mode, pm_init() will set the mode
+** of stdin and stdout to binary for all Netpbm programs.
+** You need this with Cygwin (Windows).
+*/
 #if MSVCRT || defined(__CYGWIN__) || defined(DJGPP)
 #define HAVE_SETMODE
 #endif
 
-/* #define HAVE_SETMODE */
+#if MSVCRT || defined(__CYGWIN__) || defined(DJGPP)
+#define HAVE_IO_H 1
+#else
+#define HAVE_IO_H 0
+#endif
 
-#if (defined(__GLIBC__) || defined(__GNU_LIBRARY__) || defined(__APPLE__))
+#if (defined(__GLIBC__) || defined(__GNU_LIBRARY__) || defined(__APPLE__)) || defined(__NetBSD__)
   #define HAVE_VASPRINTF 1
 #else
   #define HAVE_VASPRINTF 0
 #endif
 
+/* On Windows, unlinking a file is deleting it, and you can't delete an open
+   file, so unlink of an open file fails.  The errno is (incorrectly) EACCES.
+*/
+#if MSVCRT || defined(__CYGWIN__) || defined(DJGPP)
+  #define CAN_UNLINK_OPEN 0
+#else
+  #define CAN_UNLINK_OPEN 1
+#endif
+
 #ifdef __amigaos__
 #include <clib/exec_protos.h>
 #define getpid() ((pid_t)FindTask(NULL))
@@ -150,7 +165,7 @@ extern int rand();
 
 #ifdef DJGPP
 #define lstat stat
-#endif /* DJGPP */
+#endif
 
 /*  CONFIGURE: Netpbm uses __inline__ to declare functions that should
     be compiled as inline code.  GNU C recognizes the __inline__ keyword.
@@ -185,38 +200,25 @@ extern int rand();
   #endif
 #endif
 
-/* CONFIGURE: GNUC extensions are used in performance critical places
+/* CONFIGURE: GNU Compiler extensions are used in performance critical places
    when available.  Test whether they exist.
 
-   Turn off by defining NO_GCC_BUILTINS.
+   Prevent the build from exploiting these extensions by defining
+   NO_GCC_UNIQUE.
 
-   Note that though these influence the code produced, the compiler
-   setting ultimately decides what operands are used.  If you
-   want a generic build, check the manual and adjust CFLAGS in
-   config.mk accordingly.
-
-   For example, if you want binaries that run on all Intel x86-32
-   family CPUs back to 80386, adding "-march=i386" to CFLAGS in
-   config.mk is much better than setting NO_GCC_BUILTINS to 1.
-   If you want to be extra sure use:
-   "-march=i386 -mno-mmx -mno-sse -DNO_GCC_BUILTINS"
+   Before Netpbm 10.65 (December 2013), Netpbm used GCC compiler extensions
+   to generate SSE code in Pamflip.  Starting in 10.65, Netpbm instead uses
+   the more standard operators defined in <emmtrins.h>.  To prevent Netpbm
+   from explicitly using any SSE instructions, set WANT_SSE to N in
+   config.mk.
 */
 
-#if defined(__GNUC__) && !defined(NO_GCC_BUILTINS)
+#if defined(__GNUC__) && !defined(NO_GCC_UNIQUE)
   #define GCCVERSION __GNUC__*100 + __GNUC_MINOR__
 #else
   #define GCCVERSION 0
 #endif
 
-#ifndef HAVE_GCC_MMXSSE
-#if GCCVERSION >=301 && defined(__MMX__) && defined(__SSE__)
-  #define HAVE_GCC_MMXSSE 1
-  /* Use GCC builtins to directly access MMX/SSE features */ 
-#else
-  #define HAVE_GCC_MMXSSE 0
-#endif
-#endif
-
 #ifndef HAVE_GCC_BITCOUNT
 #if GCCVERSION >=304
   #define HAVE_GCC_BITCOUNT 1
@@ -228,10 +230,9 @@ extern int rand();
 #endif
 
 #ifndef HAVE_GCC_BSWAP
-#if GCCVERSION >=403
+#if GCCVERSION >=403 || defined(__clang__)
   #define HAVE_GCC_BSWAP 1
   /* Use __builtin_bswap32(), __builtin_bswap64() for endian conversion.
-     Available from GCC v 4.3 onward.
      NOTE: On intel CPUs this may produce the bswap operand which is not
      available on 80386. */
 #else
@@ -239,6 +240,35 @@ extern int rand();
 #endif
 #endif
 
+#ifndef HAVE_WORKING_SSE2
+#if defined(__SSE2__) && ( GCCVERSION >=402 || defined(__clang__) )
+  #define HAVE_WORKING_SSE2 1
+  /* We can use SSE2 builtin functions to exploit SSE2 instructions.  GCC
+     version 4.2 or newer is required; older GCC ostensibly has these SSE2
+     builtins, but the compiler aborts with an error.  Note that __SSE2__
+     means not only that the compiler has the capability, but that the user
+     has not disabled it via compiler options.
+  */
+#else
+  #define HAVE_WORKING_SSE2 0
+#endif
+#endif
+
+/* UNALIGNED_OK means it's OK to do unaligned memory access, e.g.
+   loading an 8-byte word from an address that is not a multiple of 8.
+   On some systems, such an access causes a trap and a signal.
+
+   This determination is conservative - There may be cases where unaligned
+   access is OK and we say here it isn't.
+
+   We know unaligned access is _not_ OK on at least SPARC and some ARM.
+*/
+
+#if defined(__x86_64__) | defined(__i486__) | defined(__vax__)
+# define UNALIGNED_OK 1
+#else
+# define UNALIGNED_OK 0
+#endif
 
 
 /* CONFIGURE: Some systems seem to need more than standard program linkage
@@ -300,9 +330,14 @@ typedef long int pm_filepos;
 typedef int qsort_comparison_fn(const void *, const void *);
     /* A compare function to pass to <stdlib.h>'s qsort() */
 
-#if defined(WIN32) && !defined(__CYGWIN__)
+#if MSVCRT
   #define pm_mkdir(dir, perm) _mkdir(dir)
 #else
   #define pm_mkdir(dir, perm) mkdir(dir, perm) 
 #endif
 
+#if MSVCRT
+  #define pm_pipe _pipe
+#else
+  #define pm_pipe pipe
+#endif