Print this page
5910 libnisdb won't build with modern GCC


   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  *      db_table.cc
  24  *
  25  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  26  * Use is subject to license terms.


  27  */
  28 
  29 #include <stdio.h>
  30 #include <malloc.h>
  31 #include <string.h>
  32 #include <stdlib.h>               /* srand48() */
  33 #include <lber.h>
  34 #include <ldap.h>
  35 #include "db_headers.h"
  36 #include "db_table.h"
  37 #include "db_pickle.h"    /* for dump and load */
  38 #include "db_entry.h"
  39 #include "nisdb_mt.h"
  40 
  41 #include "ldap_parse.h"
  42 #include "ldap_util.h"
  43 #include "ldap_map.h"
  44 #include "ldap_xdr.h"
  45 #include "nis_hashitem.h"
  46 #include "nisdb_ldap.h"


  57  * unsigned quantity to see if it's less than zero, we compare
  58  * to one instead. If negative, the largest possible value is
  59  * th inverse of 2**(N-1), where N is the number of bits in a
  60  * time_t.
  61  */
  62 extern "C" {
  63 static void
  64 __setMaxTimeT(void)
  65 {
  66         unsigned char   b[sizeof (time_t)];
  67         int             i;
  68 
  69         /* Compute ~0 for an unknown length integer */
  70         for (i = 0; i < sizeof (time_t); i++) {
  71                 b[i] = 0xff;
  72         }
  73         /* Set maxTimeT to ~0 of appropriate length */
  74         (void) memcpy(&maxTimeT, b, sizeof (time_t));
  75 
  76         if (maxTimeT < 1)
  77                 maxTimeT = ~(1<<((8*sizeof (maxTimeT))-1));
  78 }
  79 #pragma init(__setMaxTimeT)
  80 }
  81 
  82 /* How much to grow table by */
  83 #define DB_TABLE_GROWTH_INCREMENT 1024
  84 
  85 /* 0'th not used; might be confusing. */
  86 #define DB_TABLE_START 1
  87 
  88 /* prevents wrap around numbers from being passed */
  89 #define CALLOC_LIMIT 536870911
  90 
  91 /* Initial table sizes to use before using 1K increments. */
  92 /* This helps conserve memory usage when there are lots of small tables. */
  93 static int tabsizes[] = {
  94         16,
  95         128,
  96         512,
  97         DB_TABLE_GROWTH_INCREMENT,




   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  *      db_table.cc
  24  *
  25  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  26  * Use is subject to license terms.
  27  *
  28  * Copyright 2015 RackTop Systems.
  29  */
  30 
  31 #include <stdio.h>
  32 #include <malloc.h>
  33 #include <string.h>
  34 #include <stdlib.h>               /* srand48() */
  35 #include <lber.h>
  36 #include <ldap.h>
  37 #include "db_headers.h"
  38 #include "db_table.h"
  39 #include "db_pickle.h"    /* for dump and load */
  40 #include "db_entry.h"
  41 #include "nisdb_mt.h"
  42 
  43 #include "ldap_parse.h"
  44 #include "ldap_util.h"
  45 #include "ldap_map.h"
  46 #include "ldap_xdr.h"
  47 #include "nis_hashitem.h"
  48 #include "nisdb_ldap.h"


  59  * unsigned quantity to see if it's less than zero, we compare
  60  * to one instead. If negative, the largest possible value is
  61  * th inverse of 2**(N-1), where N is the number of bits in a
  62  * time_t.
  63  */
  64 extern "C" {
  65 static void
  66 __setMaxTimeT(void)
  67 {
  68         unsigned char   b[sizeof (time_t)];
  69         int             i;
  70 
  71         /* Compute ~0 for an unknown length integer */
  72         for (i = 0; i < sizeof (time_t); i++) {
  73                 b[i] = 0xff;
  74         }
  75         /* Set maxTimeT to ~0 of appropriate length */
  76         (void) memcpy(&maxTimeT, b, sizeof (time_t));
  77 
  78         if (maxTimeT < 1)
  79                 maxTimeT = ~(1L<<((8*sizeof (maxTimeT))-1));
  80 }
  81 #pragma init(__setMaxTimeT)
  82 }
  83 
  84 /* How much to grow table by */
  85 #define DB_TABLE_GROWTH_INCREMENT 1024
  86 
  87 /* 0'th not used; might be confusing. */
  88 #define DB_TABLE_START 1
  89 
  90 /* prevents wrap around numbers from being passed */
  91 #define CALLOC_LIMIT 536870911
  92 
  93 /* Initial table sizes to use before using 1K increments. */
  94 /* This helps conserve memory usage when there are lots of small tables. */
  95 static int tabsizes[] = {
  96         16,
  97         128,
  98         512,
  99         DB_TABLE_GROWTH_INCREMENT,