[Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.119,2.120

Fred L. Drake fdrake@weyr.cnri.reston.va.us
Wed, 15 Dec 1999 10:34:36 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/Modules
In directory weyr:/home/fdrake/projects/python/Modules

Modified Files:
	posixmodule.c 
Log Message:

Added table entries for Irix 6.5 names for confstr()/sysconf()/
pathconf() names, from Sjoerd.

Added code to verify that these tables are properly ordered, only
included and used when CHECK_CONFNAME_TABLES is defined.  This is only 
needed to test the tables, so I haven't enabled this by default.


Index: posixmodule.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.119
retrieving revision 2.120
diff -C2 -r2.119 -r2.120
*** posixmodule.c	1999/12/14 21:25:03	2.119
--- posixmodule.c	1999/12/15 15:34:33	2.120
***************
*** 3416,3419 ****
--- 3416,3425 ----
  #if defined(HAVE_FPATHCONF) || defined(HAVE_PATHCONF)
  static struct constdef  posix_constants_pathconf[] = {
+ #ifdef _PC_ABI_AIO_XFER_MAX
+     {"PC_ABI_AIO_XFER_MAX",	_PC_ABI_AIO_XFER_MAX},
+ #endif
+ #ifdef _PC_ABI_ASYNC_IO
+     {"PC_ABI_ASYNC_IO",	_PC_ABI_ASYNC_IO},
+ #endif
  #ifdef _PC_ASYNC_IO
      {"PC_ASYNC_IO",	_PC_ASYNC_IO},
***************
*** 3541,3544 ****
--- 3547,3565 ----
  #ifdef HAVE_CONFSTR
  static struct constdef posix_constants_confstr[] = {
+ #ifdef _CS_ARCHITECTURE
+     {"CS_ARCHITECTURE",	_CS_ARCHITECTURE},
+ #endif
+ #ifdef _CS_HOSTNAME
+     {"CS_HOSTNAME",	_CS_HOSTNAME},
+ #endif
+ #ifdef _CS_HW_PROVIDER
+     {"CS_HW_PROVIDER",	_CS_HW_PROVIDER},
+ #endif
+ #ifdef _CS_HW_SERIAL
+     {"CS_HW_SERIAL",	_CS_HW_SERIAL},
+ #endif
+ #ifdef _CS_INITTAB_NAME
+     {"CS_INITTAB_NAME",	_CS_INITTAB_NAME},
+ #endif
  #ifdef _CS_LFS64_CFLAGS
      {"CS_LFS64_CFLAGS",	_CS_LFS64_CFLAGS},
***************
*** 3565,3571 ****
--- 3586,3607 ----
      {"CS_LFS_LINTFLAGS",	_CS_LFS_LINTFLAGS},
  #endif
+ #ifdef _CS_MACHINE
+     {"CS_MACHINE",	_CS_MACHINE},
+ #endif
  #ifdef _CS_PATH
      {"CS_PATH",	_CS_PATH},
  #endif
+ #ifdef _CS_RELEASE
+     {"CS_RELEASE",	_CS_RELEASE},
+ #endif
+ #ifdef _CS_SRPC_DOMAIN
+     {"CS_SRPC_DOMAIN",	_CS_SRPC_DOMAIN},
+ #endif
+ #ifdef _CS_SYSNAME
+     {"CS_SYSNAME",	_CS_SYSNAME},
+ #endif
+ #ifdef _CS_VERSION
+     {"CS_VERSION",	_CS_VERSION},
+ #endif
  #ifdef _CS_XBS5_ILP32_OFF32_CFLAGS
      {"CS_XBS5_ILP32_OFF32_CFLAGS",	_CS_XBS5_ILP32_OFF32_CFLAGS},
***************
*** 3616,3619 ****
--- 3652,3694 ----
      {"CS_XBS5_LPBIG_OFFBIG_LINTFLAGS",	_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS},
  #endif
+ #ifdef _MIPS_CS_AVAIL_PROCESSORS
+     {"MIPS_CS_AVAIL_PROCESSORS",	_MIPS_CS_AVAIL_PROCESSORS},
+ #endif
+ #ifdef _MIPS_CS_BASE
+     {"MIPS_CS_BASE",	_MIPS_CS_BASE},
+ #endif
+ #ifdef _MIPS_CS_HOSTID
+     {"MIPS_CS_HOSTID",	_MIPS_CS_HOSTID},
+ #endif
+ #ifdef _MIPS_CS_HW_NAME
+     {"MIPS_CS_HW_NAME",	_MIPS_CS_HW_NAME},
+ #endif
+ #ifdef _MIPS_CS_NUM_PROCESSORS
+     {"MIPS_CS_NUM_PROCESSORS",	_MIPS_CS_NUM_PROCESSORS},
+ #endif
+ #ifdef _MIPS_CS_OSREL_MAJ
+     {"MIPS_CS_OSREL_MAJ",	_MIPS_CS_OSREL_MAJ},
+ #endif
+ #ifdef _MIPS_CS_OSREL_MIN
+     {"MIPS_CS_OSREL_MIN",	_MIPS_CS_OSREL_MIN},
+ #endif
+ #ifdef _MIPS_CS_OSREL_PATCH
+     {"MIPS_CS_OSREL_PATCH",	_MIPS_CS_OSREL_PATCH},
+ #endif
+ #ifdef _MIPS_CS_OS_NAME
+     {"MIPS_CS_OS_NAME",	_MIPS_CS_OS_NAME},
+ #endif
+ #ifdef _MIPS_CS_OS_PROVIDER
+     {"MIPS_CS_OS_PROVIDER",	_MIPS_CS_OS_PROVIDER},
+ #endif
+ #ifdef _MIPS_CS_PROCESSORS
+     {"MIPS_CS_PROCESSORS",	_MIPS_CS_PROCESSORS},
+ #endif
+ #ifdef _MIPS_CS_SERIAL
+     {"MIPS_CS_SERIAL",	_MIPS_CS_SERIAL},
+ #endif
+ #ifdef _MIPS_CS_VENDOR
+     {"MIPS_CS_VENDOR",	_MIPS_CS_VENDOR},
+ #endif
  };
  
***************
*** 3698,3701 ****
--- 3773,3782 ----
      {"SC_2_VERSION",	_SC_2_VERSION},
  #endif
+ #ifdef _SC_ABI_ASYNCHRONOUS_IO
+     {"SC_ABI_ASYNCHRONOUS_IO",	_SC_ABI_ASYNCHRONOUS_IO},
+ #endif
+ #ifdef _SC_ACL
+     {"SC_ACL",	_SC_ACL},
+ #endif
  #ifdef _SC_AIO_LISTIO_MAX
      {"SC_AIO_LISTIO_MAX",	_SC_AIO_LISTIO_MAX},
***************
*** 3719,3722 ****
--- 3800,3806 ----
      {"SC_ATEXIT_MAX",	_SC_ATEXIT_MAX},
  #endif
+ #ifdef _SC_AUDIT
+     {"SC_AUDIT",	_SC_AUDIT},
+ #endif
  #ifdef _SC_AVPHYS_PAGES
      {"SC_AVPHYS_PAGES",	_SC_AVPHYS_PAGES},
***************
*** 3734,3737 ****
--- 3818,3824 ----
      {"SC_BC_STRING_MAX",	_SC_BC_STRING_MAX},
  #endif
+ #ifdef _SC_CAP
+     {"SC_CAP",	_SC_CAP},
+ #endif
  #ifdef _SC_CHARCLASS_NAME_MAX
      {"SC_CHARCLASS_NAME_MAX",	_SC_CHARCLASS_NAME_MAX},
***************
*** 3803,3806 ****
--- 3890,3896 ----
      {"SC_ICACHE_SZ",	_SC_ICACHE_SZ},
  #endif
+ #ifdef _SC_INF
+     {"SC_INF",	_SC_INF},
+ #endif
  #ifdef _SC_INT_MAX
      {"SC_INT_MAX",	_SC_INT_MAX},
***************
*** 3812,3818 ****
--- 3902,3917 ----
      {"SC_IOV_MAX",	_SC_IOV_MAX},
  #endif
+ #ifdef _SC_IP_SECOPTS
+     {"SC_IP_SECOPTS",	_SC_IP_SECOPTS},
+ #endif
  #ifdef _SC_JOB_CONTROL
      {"SC_JOB_CONTROL",	_SC_JOB_CONTROL},
  #endif
+ #ifdef _SC_KERN_POINTERS
+     {"SC_KERN_POINTERS",	_SC_KERN_POINTERS},
+ #endif
+ #ifdef _SC_KERN_SIM
+     {"SC_KERN_SIM",	_SC_KERN_SIM},
+ #endif
  #ifdef _SC_LINE_MAX
      {"SC_LINE_MAX",	_SC_LINE_MAX},
***************
*** 3827,3830 ****
--- 3926,3932 ----
      {"SC_LONG_BIT",	_SC_LONG_BIT},
  #endif
+ #ifdef _SC_MAC
+     {"SC_MAC",	_SC_MAC},
+ #endif
  #ifdef _SC_MAPPED_FILES
      {"SC_MAPPED_FILES",	_SC_MAPPED_FILES},
***************
*** 3848,3851 ****
--- 3950,3956 ----
      {"SC_MESSAGE_PASSING",	_SC_MESSAGE_PASSING},
  #endif
+ #ifdef _SC_MMAP_FIXED_ALIGNMENT
+     {"SC_MMAP_FIXED_ALIGNMENT",	_SC_MMAP_FIXED_ALIGNMENT},
+ #endif
  #ifdef _SC_MQ_OPEN_MAX
      {"SC_MQ_OPEN_MAX",	_SC_MQ_OPEN_MAX},
***************
*** 3854,3857 ****
--- 3959,3965 ----
      {"SC_MQ_PRIO_MAX",	_SC_MQ_PRIO_MAX},
  #endif
+ #ifdef _SC_NACLS_MAX
+     {"SC_NACLS_MAX",	_SC_NACLS_MAX},
+ #endif
  #ifdef _SC_NGROUPS_MAX
      {"SC_NGROUPS_MAX",	_SC_NGROUPS_MAX},
***************
*** 3881,3884 ****
--- 3989,3998 ----
      {"SC_NPROCESSORS_ONLN",	_SC_NPROCESSORS_ONLN},
  #endif
+ #ifdef _SC_NPROC_CONF
+     {"SC_NPROC_CONF",	_SC_NPROC_CONF},
+ #endif
+ #ifdef _SC_NPROC_ONLN
+     {"SC_NPROC_ONLN",	_SC_NPROC_ONLN},
+ #endif
  #ifdef _SC_NZERO
      {"SC_NZERO",	_SC_NZERO},
***************
*** 3986,3989 ****
--- 4100,4106 ----
      {"SC_SIGRT_MIN",	_SC_SIGRT_MIN},
  #endif
+ #ifdef _SC_SOFTPOWER
+     {"SC_SOFTPOWER",	_SC_SOFTPOWER},
+ #endif
  #ifdef _SC_SPLIT_CACHE
      {"SC_SPLIT_CACHE",	_SC_SPLIT_CACHE},
***************
*** 4160,4163 ****
--- 4277,4333 ----
  
  
+ #ifdef CHECK_CONFNAME_TABLES
+ /* This code should not be enabled by default; it's only purpose is to
+  * test the order of constants in the configuration name tables.  The
+  * second function defined here, check_confname_tables(), is called
+  * during module initialization if CHECK_CONFNAME_TABLES is defined.
+  * This only needs to be done when changes are made to the tables.
+  */
+ static void
+ check_confname_table(table, tablesize, tablename)
+      struct constdef *table;
+      size_t tablesize;
+      char *tablename;
+ {
+     if (tablesize > 1) {
+         int i = 0;
+ 
+         for (; i < (tablesize - 1); ++i) {
+             if (strcmp(table[i].name, table[i + 1].name) >= 0) {
+                 char buffer[256];
+ 
+                 snprintf(buffer, sizeof(buffer),
+                          "confname table '%s' out of order!\n", tablename);
+                 Py_FatalError(buffer);
+             }
+         }
+     }
+ }
+ 
+ static void
+ check_confname_tables()
+ {
+ #if defined(HAVE_FPATHCONF) || defined(HAVE_PATHCONF)
+         check_confname_table(posix_constants_pathconf,
+                              sizeof(posix_constants_pathconf)
+                                / sizeof(struct constdef),
+                              "pathconf");
+ #endif
+ #ifdef HAVE_CONFSTR
+         check_confname_table(posix_constants_confstr,
+                              sizeof(posix_constants_confstr)
+                                / sizeof(struct constdef),
+                              "confstr");
+ #endif
+ #ifdef HAVE_SYSCONF
+         check_confname_table(posix_constants_sysconf,
+                              sizeof(posix_constants_sysconf)
+                                / sizeof(struct constdef),
+                              "sysconf");
+ #endif
+ }
+ #endif
+ 
+ 
  static char posix_abort__doc__[] = "\
  abort() -> does not return!\n\
***************
*** 4577,4579 ****
--- 4747,4753 ----
  
  	posix_putenv_garbage = PyDict_New();
+ 
+ #ifdef CHECK_CONFNAME_TABLES
+         check_confname_tables();
+ #endif
  }