Revision: 76064
          http://sourceforge.net/p/brlcad/code/76064
Author:   brlcad
Date:     2020-06-08 08:12:36 +0000 (Mon, 08 Jun 2020)
Log Message:
-----------
for testing, this applies rudimentary hacked updates (not intended for merge to 
trunk) that get this branch compiling again.

Modified Paths:
--------------
    brlcad/branches/opencl/CMakeLists.txt
    brlcad/branches/opencl/src/conv/step/step-g/Axis2Placement.cpp
    brlcad/branches/opencl/src/conv/step/step-g/Axis2Placement.h
    brlcad/branches/opencl/src/conv/step/step-g/CharacterizedDefinition.cpp
    brlcad/branches/opencl/src/conv/step/step-g/CharacterizedDefinition.h
    
brlcad/branches/opencl/src/conv/step/step-g/CharacterizedProductDefinition.cpp
    brlcad/branches/opencl/src/conv/step/step-g/CharacterizedProductDefinition.h
    brlcad/branches/opencl/src/conv/step/step-g/GeometricSetSelect.cpp
    brlcad/branches/opencl/src/conv/step/step-g/GeometricSetSelect.h
    brlcad/branches/opencl/src/conv/step/step-g/MeasureValue.cpp
    brlcad/branches/opencl/src/conv/step/step-g/MeasureValue.h
    brlcad/branches/opencl/src/conv/step/step-g/PCurveOrSurface.cpp
    brlcad/branches/opencl/src/conv/step/step-g/PCurveOrSurface.h
    brlcad/branches/opencl/src/conv/step/step-g/RepresentedDefinition.cpp
    brlcad/branches/opencl/src/conv/step/step-g/RepresentedDefinition.h
    brlcad/branches/opencl/src/conv/step/step-g/ShapeDefinition.cpp
    brlcad/branches/opencl/src/conv/step/step-g/ShapeDefinition.h
    brlcad/branches/opencl/src/conv/step/step-g/TrimmingSelect.cpp
    brlcad/branches/opencl/src/conv/step/step-g/TrimmingSelect.h
    brlcad/branches/opencl/src/libbg/chull3d.cpp
    brlcad/branches/opencl/src/libbu/y2038/README.txt
    brlcad/branches/opencl/src/libbu/y2038/time64.c
    brlcad/branches/opencl/src/libbu/y2038/time64.h
    brlcad/branches/opencl/src/libbu/y2038/time64_config.h
    brlcad/branches/opencl/src/libbu/y2038/time64_limits.h
    brlcad/branches/opencl/src/libgcv/plugins/fastgen4/fastgen4_write.cpp
    brlcad/branches/opencl/src/libgcv/plugins/rhino/rhino_read.cpp
    brlcad/branches/opencl/src/libged/simulate/rt_collision_algorithm.cpp
    brlcad/branches/opencl/src/librt/primitives/ebm/ebm.c
    brlcad/branches/opencl/src/librt/reduce_db.cpp
    brlcad/branches/opencl/src/other/gdal/port/cpl_config.h.in
    brlcad/branches/opencl/src/other/openNURBS/opennurbs_archive.cpp
    brlcad/branches/opencl/src/other/openNURBS/opennurbs_defines.cpp
    brlcad/branches/opencl/src/other/openNURBS/opennurbs_defines.h
    brlcad/branches/opencl/src/other/openNURBS/opennurbs_zlib.cpp

Modified: brlcad/branches/opencl/CMakeLists.txt
===================================================================
--- brlcad/branches/opencl/CMakeLists.txt       2020-06-08 02:05:52 UTC (rev 
76063)
+++ brlcad/branches/opencl/CMakeLists.txt       2020-06-08 08:12:36 UTC (rev 
76064)
@@ -2544,6 +2544,7 @@
   message("***********************************************************")
 endif(BRLCAD_PRINT_MSGS)
 
+include(CheckSymbolExists)
 
 # ALLOCA test - based on AC_FUNC_ALLOCA
 BRLCAD_ALLOCA()

Modified: brlcad/branches/opencl/src/conv/step/step-g/Axis2Placement.cpp
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/Axis2Placement.cpp      
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/Axis2Placement.cpp      
2020-06-08 08:12:36 UTC (rev 76064)
@@ -48,7 +48,7 @@
     step = NULL;
     id = 0;
     value = NULL;
-    type = Axis2Placement::UNKNOWN;
+    type = Axis2Placement::UNKNOWN_AXIS;
 }
 
 Axis2Placement::Axis2Placement(STEPWrapper *sw, int step_id)
@@ -56,7 +56,7 @@
     step = sw;
     id = step_id;
     value = NULL;
-    type = Axis2Placement::UNKNOWN;
+    type = Axis2Placement::UNKNOWN_AXIS;
 }
 
 Axis2Placement::~Axis2Placement()
@@ -104,7 +104,7 @@
            type = Axis2Placement::AXIS2_PLACEMENT_3D;
            value = dynamic_cast<Placement *>(Factory::CreateObject(sw, 
(SDAI_Application_instance *)a3));
        } else {
-           type = Axis2Placement::UNKNOWN;
+           type = Axis2Placement::UNKNOWN_AXIS;
        }
     }
 

Modified: brlcad/branches/opencl/src/conv/step/step-g/Axis2Placement.h
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/Axis2Placement.h        
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/Axis2Placement.h        
2020-06-08 08:12:36 UTC (rev 76064)
@@ -41,7 +41,7 @@
     enum axis2_placement_type {
        AXIS2_PLACEMENT_2D,
        AXIS2_PLACEMENT_3D,
-       UNKNOWN
+       UNKNOWN_AXIS
     };
 
 protected:

Modified: 
brlcad/branches/opencl/src/conv/step/step-g/CharacterizedDefinition.cpp
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/CharacterizedDefinition.cpp     
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/CharacterizedDefinition.cpp     
2020-06-08 08:12:36 UTC (rev 76064)
@@ -40,7 +40,7 @@
     step = NULL;
     id = 0;
     definition = NULL;
-    type = CharacterizedDefinition::UNKNOWN;
+    type = CharacterizedDefinition::UNKNOWN_CHARACTERIZED;
 }
 
 CharacterizedDefinition::CharacterizedDefinition(STEPWrapper *sw,int step_id) {
@@ -47,7 +47,7 @@
     step = sw;
     id = step_id;
     definition = NULL;
-    type = CharacterizedDefinition::UNKNOWN;
+    type = CharacterizedDefinition::UNKNOWN_CHARACTERIZED;
 }
 
 CharacterizedDefinition::~CharacterizedDefinition() {
@@ -162,7 +162,7 @@
            definition = dynamic_cast<CharacterizedObject 
*>(Factory::CreateObject(sw, (SDAI_Application_instance *)pdr));
 #endif
        } else {
-           type = CharacterizedDefinition::UNKNOWN;
+           type = CharacterizedDefinition::UNKNOWN_CHARACTERIZED;
            definition = NULL;
        }
     }

Modified: brlcad/branches/opencl/src/conv/step/step-g/CharacterizedDefinition.h
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/CharacterizedDefinition.h       
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/CharacterizedDefinition.h       
2020-06-08 08:12:36 UTC (rev 76064)
@@ -43,7 +43,7 @@
 #endif
        CHARACTERIZED_PRODUCT_DEFINITION,
        SHAPE_DEFINITION,
-       UNKNOWN
+       UNKNOWN_CHARACTERIZED
     };
 
 private:

Modified: 
brlcad/branches/opencl/src/conv/step/step-g/CharacterizedProductDefinition.cpp
===================================================================
--- 
brlcad/branches/opencl/src/conv/step/step-g/CharacterizedProductDefinition.cpp  
    2020-06-08 02:05:52 UTC (rev 76063)
+++ 
brlcad/branches/opencl/src/conv/step/step-g/CharacterizedProductDefinition.cpp  
    2020-06-08 08:12:36 UTC (rev 76064)
@@ -40,7 +40,7 @@
     step = NULL;
     id = 0;
     definition = NULL;
-    type = CharacterizedProductDefinition::UNKNOWN;
+    type = CharacterizedProductDefinition::UNKNOWN_PRODUCT;
 }
 
 CharacterizedProductDefinition::CharacterizedProductDefinition(STEPWrapper 
*sw,int step_id) {
@@ -47,7 +47,7 @@
     step = sw;
     id = step_id;
     definition = NULL;
-    type = CharacterizedProductDefinition::UNKNOWN;
+    type = CharacterizedProductDefinition::UNKNOWN_PRODUCT;
 }
 
 CharacterizedProductDefinition::~CharacterizedProductDefinition() {
@@ -135,7 +135,7 @@
            type = 
CharacterizedProductDefinition::PRODUCT_DEFINITION_RELATIONSHIP;
            definition = dynamic_cast<ProductDefinitionRelationship 
*>(Factory::CreateObject(sw, (SDAI_Application_instance *)pdr));
        } else {
-           type = CharacterizedProductDefinition::UNKNOWN;
+           type = CharacterizedProductDefinition::UNKNOWN_PRODUCT;
            definition = NULL;
        }
     }

Modified: 
brlcad/branches/opencl/src/conv/step/step-g/CharacterizedProductDefinition.h
===================================================================
--- 
brlcad/branches/opencl/src/conv/step/step-g/CharacterizedProductDefinition.h    
    2020-06-08 02:05:52 UTC (rev 76063)
+++ 
brlcad/branches/opencl/src/conv/step/step-g/CharacterizedProductDefinition.h    
    2020-06-08 08:12:36 UTC (rev 76064)
@@ -41,7 +41,7 @@
 #endif
        PRODUCT_DEFINITION,
        PRODUCT_DEFINITION_RELATIONSHIP,
-       UNKNOWN
+       UNKNOWN_PRODUCT
     };
 
 private:

Modified: brlcad/branches/opencl/src/conv/step/step-g/GeometricSetSelect.cpp
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/GeometricSetSelect.cpp  
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/GeometricSetSelect.cpp  
2020-06-08 08:12:36 UTC (rev 76064)
@@ -41,7 +41,7 @@
     step = NULL;
     id = 0;
     element = NULL;
-    type = GeometricSetSelect::UNKNOWN;
+    type = GeometricSetSelect::UNKNOWN_GEOMETRIC;
 }
 
 GeometricSetSelect::GeometricSetSelect(STEPWrapper *sw,int step_id) {
@@ -48,7 +48,7 @@
     step = sw;
     id = step_id;
     element = NULL;
-    type = GeometricSetSelect::UNKNOWN;
+    type = GeometricSetSelect::UNKNOWN_GEOMETRIC;
 }
 
 GeometricSetSelect::~GeometricSetSelect() {
@@ -92,7 +92,7 @@
            type = GeometricSetSelect::SURFACE;
            element = aSurface;
        } else {
-           type = GeometricSetSelect::UNKNOWN;
+           type = GeometricSetSelect::UNKNOWN_GEOMETRIC;
            element = NULL;
        }
     }

Modified: brlcad/branches/opencl/src/conv/step/step-g/GeometricSetSelect.h
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/GeometricSetSelect.h    
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/GeometricSetSelect.h    
2020-06-08 08:12:36 UTC (rev 76064)
@@ -41,7 +41,7 @@
        POINT,
        CURVE,
        SURFACE,
-       UNKNOWN
+       UNKNOWN_GEOMETRIC
     };
 
 private:

Modified: brlcad/branches/opencl/src/conv/step/step-g/MeasureValue.cpp
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/MeasureValue.cpp        
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/MeasureValue.cpp        
2020-06-08 08:12:36 UTC (rev 76064)
@@ -63,7 +63,7 @@
 {
     step = NULL;
     id = 0;
-    type = MeasureValue::UNKNOWN;
+    type = MeasureValue::UNKNOWN_MEASURE;
     ivalue = 0;
     rvalue = 0.0;
 }
@@ -72,7 +72,7 @@
 {
     step = sw;
     id = step_id;
-    type = MeasureValue::UNKNOWN;
+    type = MeasureValue::UNKNOWN_MEASURE;
     ivalue = 0;
     rvalue = 0.0;
 }

Modified: brlcad/branches/opencl/src/conv/step/step-g/MeasureValue.h
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/MeasureValue.h  2020-06-08 
02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/MeasureValue.h  2020-06-08 
08:12:36 UTC (rev 76064)
@@ -55,7 +55,7 @@
        THERMODYNAMIC_TEMPERATURE_MEASURE,
        TIME_MEASURE,
        VOLUME_MEASURE,
-       UNKNOWN
+       UNKNOWN_MEASURE
     };
 
 private:

Modified: brlcad/branches/opencl/src/conv/step/step-g/PCurveOrSurface.cpp
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/PCurveOrSurface.cpp     
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/PCurveOrSurface.cpp     
2020-06-08 08:12:36 UTC (rev 76064)
@@ -51,7 +51,7 @@
     id = 0;
     pcurve = NULL;
     surface = NULL;
-    type = PCurveOrSurface::UNKNOWN;
+    type = PCurveOrSurface::UNKNOWN_PCURVE;
 }
 
 PCurveOrSurface::PCurveOrSurface(STEPWrapper *sw, int step_id)
@@ -60,7 +60,7 @@
     id = step_id;
     pcurve = NULL;
     surface = NULL;
-    type = PCurveOrSurface::UNKNOWN;
+    type = PCurveOrSurface::UNKNOWN_PCURVE;
 }
 
 PCurveOrSurface::~PCurveOrSurface()

Modified: brlcad/branches/opencl/src/conv/step/step-g/PCurveOrSurface.h
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/PCurveOrSurface.h       
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/PCurveOrSurface.h       
2020-06-08 08:12:36 UTC (rev 76064)
@@ -38,7 +38,7 @@
     enum pcurve_or_surface_type {
        PCURVE,
        SURFACE,
-       UNKNOWN
+       UNKNOWN_PCURVE
     };
 
 private:

Modified: brlcad/branches/opencl/src/conv/step/step-g/RepresentedDefinition.cpp
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/RepresentedDefinition.cpp       
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/RepresentedDefinition.cpp       
2020-06-08 08:12:36 UTC (rev 76064)
@@ -46,7 +46,7 @@
     step = NULL;
     id = 0;
     entity = NULL;
-    type = RepresentedDefinition::UNKNOWN;
+    type = RepresentedDefinition::UNKNOWN_RD;
 }
 
 RepresentedDefinition::RepresentedDefinition(STEPWrapper *sw,int step_id) {
@@ -53,7 +53,7 @@
     step = sw;
     id = step_id;
     entity = NULL;
-    type = RepresentedDefinition::UNKNOWN;
+    type = RepresentedDefinition::UNKNOWN_RD;
 }
 
 RepresentedDefinition::~RepresentedDefinition() {

Modified: brlcad/branches/opencl/src/conv/step/step-g/RepresentedDefinition.h
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/RepresentedDefinition.h 
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/RepresentedDefinition.h 
2020-06-08 08:12:36 UTC (rev 76064)
@@ -43,7 +43,7 @@
        PROPERTY_DEFINITION_RELATIONSHIP,
        SHAPE_ASPECT,
        SHAPE_ASPECT_RELATIONSHIP,
-       UNKNOWN
+       UNKNOWN_RD
     };
 
 protected:

Modified: brlcad/branches/opencl/src/conv/step/step-g/ShapeDefinition.cpp
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/ShapeDefinition.cpp     
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/ShapeDefinition.cpp     
2020-06-08 08:12:36 UTC (rev 76064)
@@ -40,7 +40,7 @@
     step = NULL;
     id = 0;
     definition = NULL;
-    type = ShapeDefinition::UNKNOWN;
+    type = ShapeDefinition::UNKNOWN_SHAPE;
 }
 
 ShapeDefinition::ShapeDefinition(STEPWrapper *sw,int step_id) {
@@ -47,7 +47,7 @@
     step = sw;
     id = step_id;
     definition = NULL;
-    type = ShapeDefinition::UNKNOWN;
+    type = ShapeDefinition::UNKNOWN_SHAPE;
 }
 
 ShapeDefinition::~ShapeDefinition() {
@@ -88,7 +88,7 @@
            definition = dynamic_cast<ShapeAspectRelationship 
*>(Factory::CreateObject(sw, (SDAI_Application_instance *)sar));
            if (!definition) return false;
        } else {
-           type = ShapeDefinition::UNKNOWN;
+           type = ShapeDefinition::UNKNOWN_SHAPE;
            definition = NULL;
        }
     }

Modified: brlcad/branches/opencl/src/conv/step/step-g/ShapeDefinition.h
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/ShapeDefinition.h       
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/ShapeDefinition.h       
2020-06-08 08:12:36 UTC (rev 76064)
@@ -41,7 +41,7 @@
        PRODUCT_DEFINITION_SHAPE,
        SHAPE_ASPECT,
        SHAPE_ASPECT_RELATIONSHIP,
-       UNKNOWN
+       UNKNOWN_SHAPE
     };
 
 private:

Modified: brlcad/branches/opencl/src/conv/step/step-g/TrimmingSelect.cpp
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/TrimmingSelect.cpp      
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/TrimmingSelect.cpp      
2020-06-08 08:12:36 UTC (rev 76064)
@@ -47,7 +47,7 @@
     id = 0;
     cartesian_point = NULL;
     parameter_value = 0.0;
-    type = TrimmingSelect::UNKNOWN;
+    type = TrimmingSelect::UNKNOWN_TS;
 }
 
 TrimmingSelect::TrimmingSelect(STEPWrapper *sw, int step_id)
@@ -56,7 +56,7 @@
     id = step_id;
     cartesian_point = NULL;
     parameter_value = 0.0;
-    type = TrimmingSelect::UNKNOWN;
+    type = TrimmingSelect::UNKNOWN_TS;
 }
 
 TrimmingSelect::~TrimmingSelect()

Modified: brlcad/branches/opencl/src/conv/step/step-g/TrimmingSelect.h
===================================================================
--- brlcad/branches/opencl/src/conv/step/step-g/TrimmingSelect.h        
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/conv/step/step-g/TrimmingSelect.h        
2020-06-08 08:12:36 UTC (rev 76064)
@@ -37,7 +37,7 @@
     enum trimming_select_type {
        CARTESIAN_POINT,
        PARAMETER_VALUE,
-       UNKNOWN
+       UNKNOWN_TS
     };
 
 private:

Modified: brlcad/branches/opencl/src/libbg/chull3d.cpp
===================================================================
--- brlcad/branches/opencl/src/libbg/chull3d.cpp        2020-06-08 02:05:52 UTC 
(rev 76063)
+++ brlcad/branches/opencl/src/libbg/chull3d.cpp        2020-06-08 08:12:36 UTC 
(rev 76064)
@@ -572,25 +572,6 @@
     chull3d_free_Tree_storage(cdata);
 }
 
-HIDDEN void
-chull3d_visit_fg_i(struct chull3d_data *cdata, void (*v_fg)(struct 
chull3d_data *,Tree *, int, int),
-       Tree *t, int depth, int vn, int boundary)
-{
-    int        boundaryc = boundary;
-
-    if (!t) return;
-
-    //assert(t->fgs);
-    if (t->fgs->mark!=vn) {
-       t->fgs->mark = vn;
-       if (t->key!=cdata->hull_infinity && !cdata->mo[cdata->site_num((void 
*)cdata, t->key)]) boundaryc = 0;
-       v_fg(cdata, t,depth, boundaryc);
-       chull3d_visit_fg_i(cdata, v_fg, t->fgs->facets,depth+1, vn, boundaryc);
-    }
-    chull3d_visit_fg_i(cdata, v_fg, t->left,depth,vn, boundary);
-    chull3d_visit_fg_i(cdata, v_fg, t->right,depth,vn,boundary);
-}
-
 #if 0
 HIDDEN void
 chull3d_visit_fg(struct chull3d_data *cdata, fg *faces_gr, void (*v_fg)(struct 
chull3d_data *, Tree *, int, int))
@@ -599,26 +580,6 @@
 }
 #endif
 
-HIDDEN int
-chull3d_visit_fg_i_far(struct chull3d_data *cdata, void (*v_fg)(struct 
chull3d_data *, Tree *, int),
-       Tree *t, int depth, int vn)
-{
-    int nb = 0;
-
-    if (!t) return 0;
-
-    //assert(t->fgs);
-    if (t->fgs->mark!=vn) {
-       t->fgs->mark = vn;
-       nb = (t->key==cdata->hull_infinity) || cdata->mo[cdata->site_num((void 
*)cdata, t->key)];
-       if (!nb && !chull3d_visit_fg_i_far(cdata, v_fg, 
t->fgs->facets,depth+1,vn))
-           v_fg(cdata, t,depth);
-    }
-    nb = chull3d_visit_fg_i_far(cdata, v_fg, t->left,depth,vn) || nb;
-    nb = chull3d_visit_fg_i_far(cdata, v_fg, t->right,depth,vn) || nb;
-    return nb;
-}
-
 #if 0
 HIDDEN void
 chull3d_visit_fg_far(struct chull3d_data *cdata, fg *faces_gr, void 
(*v_fg)(struct chull3d_data *, Tree *, int))

Modified: brlcad/branches/opencl/src/libbu/y2038/README.txt
===================================================================
--- brlcad/branches/opencl/src/libbu/y2038/README.txt   2020-06-08 02:05:52 UTC 
(rev 76063)
+++ brlcad/branches/opencl/src/libbu/y2038/README.txt   2020-06-08 08:12:36 UTC 
(rev 76064)
@@ -38,11 +38,11 @@
 ---------------------------
 
 localtime64_r() gets its time zone and daylight savings time
-information by mapping the future year back to a similar one between
+information by mappping the future year back to a similar one between
 2010 and 2037, safe for localtime_r().  The calculations are accurate
 according to current time zone and daylight savings information, but
 may become inaccurate if a change is made that takes place after 2010.
-But it's better to be off by an hour than 137 years.
+But its better to be off by an hour than 137 years.
 
 Future versions will probe for a 64 bit safe system localtime_r() and
 gmtime_r() and use that.  You can manually set the safe range of your
@@ -60,8 +60,4 @@
 I would like to add some configuration detection stuff in the future, but
 for now all I can do is document the assumptions...
 
-This code assumes that long longs are 64 bit integers which is technically
-in violation of the C standard.  This can be changed in time64.h by
-changing the Time64_T and Int64 typedefs.
-
 There are a number of configuration options in time64.h.

Modified: brlcad/branches/opencl/src/libbu/y2038/time64.c
===================================================================
--- brlcad/branches/opencl/src/libbu/y2038/time64.c     2020-06-08 02:05:52 UTC 
(rev 76063)
+++ brlcad/branches/opencl/src/libbu/y2038/time64.c     2020-06-08 08:12:36 UTC 
(rev 76064)
@@ -1,4 +1,4 @@
-/*
+/* 
 
 Copyright (c) 2007-2010  Michael G Schwern
 
@@ -30,7 +30,7 @@
 
 Programmers who have available to them 64-bit time values as a 'long
 long' type can use localtime64_r() and gmtime64_r() which correctly
-converts the time even on 32-bit systems. Whether you have 64-bit time
+converts the time even on 32-bit systems. Whether you have 64-bit time 
 values will depend on the operating system.
 
 localtime64_r() is a 64-bit equivalent of localtime_r().
@@ -39,8 +39,6 @@
 
 */
 
-#include "common.h"
-
 #include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -50,52 +48,7 @@
 #include "time64.h"
 #include "time64_limits.h"
 
-/* Max/min for mktime() */
-/* MODIFIED: Assign to each field so as not to depend on system field
-   ordering
-*/
-static struct tm SYSTEM_MKTIME_MAX;
-static struct tm SYSTEM_MKTIME_MIN;
 
-static int mktime_maxmin_initialized = 0;
-
-void initialize_mktime_maxmin()
-{
-  SYSTEM_MKTIME_MAX.tm_sec = 7;
-  SYSTEM_MKTIME_MAX.tm_min = 14;
-  SYSTEM_MKTIME_MAX.tm_hour = 19;
-  SYSTEM_MKTIME_MAX.tm_mday = 18;
-  SYSTEM_MKTIME_MAX.tm_mon = 0;
-  SYSTEM_MKTIME_MAX.tm_year = 138;
-  SYSTEM_MKTIME_MAX.tm_wday = 1;
-  SYSTEM_MKTIME_MAX.tm_yday = 17;
-  SYSTEM_MKTIME_MAX.tm_isdst = 0;
-#ifdef HAS_TM_TM_GMTOFF
-  SYSTEM_MKTIME_MAX.tm_gmtoff = -28800;
-#endif
-#ifdef HAS_TM_TM_ZONE
-  SYSTEM_MKTIME_MAX.tm_zone = "PST";
-#endif
-
-  SYSTEM_MKTIME_MIN.tm_sec = 52;
-  SYSTEM_MKTIME_MIN.tm_min = 45;
-  SYSTEM_MKTIME_MIN.tm_hour = 12;
-  SYSTEM_MKTIME_MIN.tm_mday = 13;
-  SYSTEM_MKTIME_MIN.tm_mon = 11;
-  SYSTEM_MKTIME_MIN.tm_year = 1;
-  SYSTEM_MKTIME_MIN.tm_wday = 5;
-  SYSTEM_MKTIME_MIN.tm_yday = 346;
-  SYSTEM_MKTIME_MIN.tm_isdst = 0;
-#ifdef HAS_TM_TM_GMTOFF
-  SYSTEM_MKTIME_MIN.tm_gmtoff = 2880;
-#endif
-#ifdef HAS_TM_TM_ZONE
-  SYSTEM_MKTIME_MIN.tm_zone = "PST";
-#endif
-
-  mktime_maxmin_initialized = 1;
-}
-
 /* Spec says except for stftime() and the _r() functions, these
    all return static memory.  Stabbings! */
 static struct TM   Static_Return_Date;
@@ -156,16 +109,18 @@
     1992, 1993, 1994, 1995,
 };
 
-/* /\* This isn't used, but it's handy to look at *\/ */
-/* static const char dow_year_start[SOLAR_CYCLE_LENGTH] = { */
-/*     5, 0, 1, 2,     /\* 0       2016 - 2019 *\/ */
-/*     3, 5, 6, 0,     /\* 4  *\/ */
-/*     1, 3, 4, 5,     /\* 8       1996 - 1998, 1971*\/ */
-/*     6, 1, 2, 3,     /\* 12      1972 - 1975 *\/ */
-/*     4, 6, 0, 1,     /\* 16 *\/ */
-/*     2, 4, 5, 6,     /\* 20      2036, 2037, 2010, 2011 *\/ */
-/*     0, 2, 3, 4      /\* 24      2012, 2013, 2014, 2015 *\/ */
-/* }; */
+#if 0
+/* This isn't used, but it's handy to look at */
+static const char dow_year_start[SOLAR_CYCLE_LENGTH] = {
+    5, 0, 1, 2,     /* 0       2016 - 2019 */
+    3, 5, 6, 0,     /* 4  */
+    1, 3, 4, 5,     /* 8       1996 - 1998, 1971*/
+    6, 1, 2, 3,     /* 12      1972 - 1975 */
+    4, 6, 0, 1,     /* 16 */
+    2, 4, 5, 6,     /* 20      2036, 2037, 2010, 2011 */
+    0, 2, 3, 4      /* 24      2012, 2013, 2014, 2015 */
+};
+#endif
 
 /* Let's assume people are going to be looking for dates in the future.
    Let's provide some cheats so you can skip ahead.
@@ -175,9 +130,13 @@
 #define CHEAT_DAYS  (1199145600 / 24 / 60 / 60)
 #define CHEAT_YEARS 108
 
-#define IS_LEAP(n)      ((!(((n) + 1900) % 400) || (!(((n) + 1900) % 4) && 
(((n) + 1900) % 100))) != 0)
-#define WRAP(a,b,m)     ((a) = ((a) <  0  ) ? ((b)--, (a) + (m)) : (a))
+/* IS_LEAP is used all over the place to index on arrays, so make sure it 
always returns 0 or 1. */
+#define IS_LEAP(n)  ( (!(((n) + 1900) % 400) || (!(((n) + 1900) % 4) && (((n) 
+ 1900) % 100))) ? 1 : 0 )
+#define IS_LEAP_ABS(n)  (!((n) % 400) || (!((n) % 4) && ((n) % 100) && ((n) > 
0)))
 
+/* Allegedly, some <termios.h> define a macro called WRAP, so use a longer 
name like WRAP_TIME64. */
+#define WRAP_TIME64(a,b,m)     ((a) = ((a) <  0  ) ? ((b)--, (a) + (m)) : (a))
+
 #ifdef USE_SYSTEM_LOCALTIME
 #    define SHOULD_USE_SYSTEM_LOCALTIME(a)  (       \
     (a) <= SYSTEM_LOCALTIME_MAX &&              \
@@ -223,7 +182,7 @@
    The result is like cmp.
    Ignores things like gmtoffset and dst
 */
-int cmp_date( const struct TM* left, const struct tm* right ) {
+static int cmp_date( const struct TM* left, const struct tm* right ) {
     if( left->tm_year > right->tm_year )
         return 1;
     else if( left->tm_year < right->tm_year )
@@ -259,9 +218,9 @@
 
 
 /* Check if a date is safely inside a range.
-   The intention is to check if it's a few days inside.
+   The intention is to check if its a few days inside.
 */
-int date_in_safe_range( const struct TM* date, const struct tm* min, const 
struct tm* max ) {
+static int date_in_safe_range( const struct TM* date, const struct tm* min, 
const struct tm* max ) {
     if( cmp_date(date, min) == -1 )
         return 0;
 
@@ -281,19 +240,19 @@
     Time64_T seconds = 0;
     Year     year;
     Year     orig_year = (Year)date->tm_year;
-    int      cycles  = 0;
+    Year     cycles  = 0;
 
     if( orig_year > 100 ) {
         cycles = (orig_year - 100) / 400;
         orig_year -= cycles * 400;
-        days      += (Time64_T)cycles * days_in_gregorian_cycle;
+        days      += cycles * days_in_gregorian_cycle;
     }
     else if( orig_year < -300 ) {
         cycles = (orig_year - 100) / 400;
         orig_year -= cycles * 400;
-        days      += (Time64_T)cycles * days_in_gregorian_cycle;
+        days      += cycles * days_in_gregorian_cycle;
     }
-    TIME64_TRACE3("# timegm/ cycles: %d, days: %lld, orig_year: %lld\n", 
cycles, days, orig_year);
+    TIME64_TRACE3("# timegm/ cycles: %"PRId64", days: %"PRId64", orig_year: 
%"PRId64"\n", cycles, days, orig_year);
 
     if( orig_year > 70 ) {
         year = 70;
@@ -322,6 +281,43 @@
     return(seconds);
 }
 
+
+static int check_tm(struct TM *tm)
+{
+    /* Don't forget leap seconds */
+    assert(tm->tm_sec >= 0);
+
+    /* Allow for just one positive leap second, which is what the C99 standard 
says. */
+    /* Two leap seconds in the same minute are not allowed (the C90 range 
0..61 was a defect). */
+    assert(tm->tm_sec <= 60);
+
+    assert(tm->tm_min >= 0);
+    assert(tm->tm_min <= 59);
+
+    assert(tm->tm_hour >= 0);
+    assert(tm->tm_hour <= 23);
+
+    assert(tm->tm_mday >= 1);
+    assert(tm->tm_mday <= days_in_month[IS_LEAP(tm->tm_year)][tm->tm_mon]);
+
+    assert(tm->tm_mon  >= 0);
+    assert(tm->tm_mon  <= 11);
+
+    assert(tm->tm_wday >= 0);
+    assert(tm->tm_wday <= 6);
+    
+    assert(tm->tm_yday >= 0);
+    assert(tm->tm_yday <= length_of_year[IS_LEAP(tm->tm_year)]);
+
+#ifdef HAS_TM_TM_GMTOFF
+    assert(tm->tm_gmtoff >= -24 * 60 * 60);
+    assert(tm->tm_gmtoff <=  24 * 60 * 60);
+#endif
+
+    return 1;
+}
+
+
 /* The exceptional centuries without leap years cause the cycle to
    shift by 16
 */
@@ -337,7 +333,7 @@
     exceptions  = year_diff / 100;
     exceptions -= year_diff / 400;
 
-    TIME64_TRACE3("# year: %lld, exceptions: %lld, year_diff: %lld\n",
+    TIME64_TRACE3("# year: %"PRId64", exceptions: %"PRId64", year_diff: 
%"PRId64"\n",
           year, exceptions, year_diff);
 
     return exceptions * 16;
@@ -359,13 +355,10 @@
    is for Dec 31st with a +UTC time zone.
    It doesn't need the same leap year status since we only care about
    January 1st.
-
-   MODIFIED: Compile better by renaming safe_year variable to not
-   shadow function.
 */
 static int safe_year(const Year year)
 {
-    int ret;
+    int safe_year;
     Year year_cycle;
 
     if( year >= MIN_SAFE_YEAR && year <= MAX_SAFE_YEAR ) {
@@ -387,28 +380,28 @@
         year_cycle += 17;
 
     year_cycle %= SOLAR_CYCLE_LENGTH;
-    if( year_cycle < 0 )
+    if( year_cycle < 0 ) 
         year_cycle = SOLAR_CYCLE_LENGTH + year_cycle;
 
     assert( year_cycle >= 0 );
     assert( year_cycle < SOLAR_CYCLE_LENGTH );
     if( year < MIN_SAFE_YEAR )
-        ret = safe_years_low[year_cycle];
+        safe_year = safe_years_low[year_cycle];
     else if( year > MAX_SAFE_YEAR )
-        ret = safe_years_high[year_cycle];
+        safe_year = safe_years_high[year_cycle];
     else
         assert(0);
 
-    TIME64_TRACE3("# year: %lld, year_cycle: %lld, safe_year: %d\n",
-          year, year_cycle, ret);
+    TIME64_TRACE3("# year: %"PRId64", year_cycle: %"PRId64", safe_year: %d\n",
+          year, year_cycle, safe_year);
 
-    assert(ret <= MAX_SAFE_YEAR && ret >= MIN_SAFE_YEAR);
+    assert(safe_year <= MAX_SAFE_YEAR && safe_year >= MIN_SAFE_YEAR);
 
-    return ret;
+    return safe_year;
 }
 
 
-void copy_tm_to_TM64(const struct tm *src, struct TM *dest) {
+static void copy_tm_to_TM64(const struct tm *src, struct TM *dest) {
     if( src == NULL ) {
         memset(dest, 0, sizeof(*dest));
     }
@@ -440,7 +433,7 @@
 }
 
 
-void copy_TM64_to_tm(const struct TM *src, struct tm *dest) {
+static void copy_TM64_to_tm(const struct TM *src, struct tm *dest) {
     if( src == NULL ) {
         memset(dest, 0, sizeof(*dest));
     }
@@ -473,9 +466,11 @@
 
 
 /* Simulate localtime_r() to the best of our ability */
-struct tm * fake_localtime_r(const time_t *ytime, struct tm *result) {
-    const struct tm *static_result = localtime(ytime);
+#ifndef HAS_LOCALTIME_R
 
+struct tm * fake_localtime_r(const time_t *time, struct tm *result) {
+    const struct tm *static_result = localtime(time);
+
     assert(result != NULL);
 
     if( static_result == NULL ) {
@@ -488,11 +483,15 @@
     }
 }
 
+#endif  /* #ifndef HAS_LOCALTIME_R */
 
+
 /* Simulate gmtime_r() to the best of our ability */
-struct tm * fake_gmtime_r(const time_t *ytime, struct tm *result) {
-    const struct tm *static_result = gmtime(ytime);
+#ifndef HAS_GMTIME_R
 
+struct tm * fake_gmtime_r(const time_t *time, struct tm *result) {
+    const struct tm *static_result = gmtime(time);
+
     assert(result != NULL);
 
     if( static_result == NULL ) {
@@ -505,29 +504,44 @@
     }
 }
 
+#endif  /* #ifndef HAS_GMTIME_R */
 
+
 static Time64_T seconds_between_years(Year left_year, Year right_year) {
     int increment = (left_year > right_year) ? 1 : -1;
     Time64_T seconds = 0;
-    int cycles;
+    Year cycles;
 
     if( left_year > 2400 ) {
+        TIME64_TRACE1("year %"PRId64" > 2400\n", left_year);
         cycles = (left_year - 2400) / 400;
         left_year -= cycles * 400;
         seconds   += cycles * seconds_in_gregorian_cycle;
     }
     else if( left_year < 1600 ) {
+        TIME64_TRACE1("year %"PRId64" < 1600\n", left_year);
         cycles = (left_year - 1600) / 400;
         left_year += cycles * 400;
         seconds   += cycles * seconds_in_gregorian_cycle;
     }
 
-    while( left_year != right_year ) {
-        seconds += length_of_year[IS_LEAP(right_year - 1900)] * 60 * 60 * 24;
-        right_year += increment;
+    if (increment > 0) {
+        TIME64_TRACE2("year %"PRId64" > safe_year %"PRId64"\n", left_year, 
right_year);
+        while( left_year != right_year ) {
+            seconds += length_of_year[IS_LEAP_ABS(right_year)] * 60 * 60 * 24;
+            right_year++;
+        }
+        TIME64_TRACE1("adjust by %"PRId64" days\n", seconds / (60 * 60 * 24));
+        return seconds;
+    } else {
+        TIME64_TRACE2("year %"PRId64" < safe_year %"PRId64"\n", left_year, 
right_year);
+        while( left_year != right_year ) {
+            seconds -= length_of_year[IS_LEAP_ABS(right_year)] * 60 * 60 * 24;
+            right_year--;
+        }
+        TIME64_TRACE1("adjust by %"PRId64" days\n", seconds / (60 * 60 * 24));
+        return seconds;
     }
-
-    return seconds * increment;
 }
 
 
@@ -534,40 +548,35 @@
 Time64_T mktime64(struct TM *input_date) {
     struct tm safe_date;
     struct TM date;
-    Time64_T  ytime;
+    Time64_T  time;
     Year      year = input_date->tm_year + 1900;
 
-    /* MODIFIED: this check added, used to make sure that the mktime()
-       max and min structures are initialized now that they are not
-       initialized through a struct literal (see above).
-    */
-    if (!mktime_maxmin_initialized)
-    {
-        initialize_mktime_maxmin();
-    }
     if( date_in_safe_range(input_date, &SYSTEM_MKTIME_MIN, &SYSTEM_MKTIME_MAX) 
)
     {
         copy_TM64_to_tm(input_date, &safe_date);
-        ytime = (Time64_T)mktime(&safe_date);
+        time = (Time64_T)mktime(&safe_date);
 
         /* Correct the possibly out of bound input date */
         copy_tm_to_TM64(&safe_date, input_date);
-        return ytime;
+        TIME64_TRACE2("mktime64: safe year %ld, %"PRId64" seconds\n", 
(long)year, time);
+        return time;
     }
 
     /* Have to make the year safe in date else it won't fit in safe_date */
     date = *input_date;
     date.tm_year = safe_year(year) - 1900;
+
     copy_TM64_to_tm(&date, &safe_date);
+    time = (Time64_T)mktime(&safe_date);
+    TIME64_TRACE1("mktime64: %"PRId64" seconds\n", time);
 
-    ytime = (Time64_T)mktime(&safe_date);
-
     /* Correct the user's possibly out of bound input date */
     copy_tm_to_TM64(&safe_date, input_date);
 
-    ytime += seconds_between_years(year, (Year)(safe_date.tm_year + 1900));
+    time += seconds_between_years(year, (Year)(safe_date.tm_year + 1900));
+    TIME64_TRACE1("mktime64 => %"PRId64" seconds\n", time);
 
-    return ytime;
+    return time;
 }
 
 
@@ -583,9 +592,9 @@
     Time64_T v_tm_tday;
     int leap;
     Time64_T m;
-    Time64_T ytime = *in_time;
+    Time64_T time = *in_time;
     Year year = 70;
-    int cycles = 0;
+    Year cycles = 0;
 
     assert(p != NULL);
 
@@ -596,6 +605,7 @@
         GMTIME_R(&safe_time, &safe_date);
 
         copy_tm_to_TM64(&safe_date, p);
+        assert(check_tm(p));
 
         return p;
     }
@@ -604,22 +614,21 @@
     p->tm_gmtoff = 0;
 #endif
     p->tm_isdst  = 0;
-
 #ifdef HAS_TM_TM_ZONE
     p->tm_zone   = "UTC";
 #endif
 
-    v_tm_sec =  (int)(ytime % 60);
-    ytime /= 60;
-    v_tm_min =  (int)(ytime % 60);
-    ytime /= 60;
-    v_tm_hour = (int)(ytime % 24);
-    ytime /= 24;
-    v_tm_tday = ytime;
+    v_tm_sec =  (int)(time % 60);
+    time /= 60;
+    v_tm_min =  (int)(time % 60);
+    time /= 60;
+    v_tm_hour = (int)(time % 24);
+    time /= 24;
+    v_tm_tday = time;
 
-    WRAP (v_tm_sec, v_tm_min, 60);
-    WRAP (v_tm_min, v_tm_hour, 60);
-    WRAP (v_tm_hour, v_tm_tday, 24);
+    WRAP_TIME64 (v_tm_sec, v_tm_min, 60);
+    WRAP_TIME64 (v_tm_min, v_tm_hour, 60);
+    WRAP_TIME64 (v_tm_hour, v_tm_tday, 24);
 
     v_tm_wday = (int)((v_tm_tday + 4) % 7);
     if (v_tm_wday < 0)
@@ -633,10 +642,10 @@
 
     if (m >= 0) {
         /* Gregorian cycles, this is huge optimization for distant times */
-        cycles = (int)(m / (Time64_T) days_in_gregorian_cycle);
+        cycles = m / (Time64_T) days_in_gregorian_cycle;
         if( cycles ) {
-            m -= (cycles * (Time64_T) days_in_gregorian_cycle);
-            year += (cycles * years_in_gregorian_cycle);
+            m -= cycles * (Time64_T) days_in_gregorian_cycle;
+            year += cycles * years_in_gregorian_cycle;
         }
 
         /* Years */
@@ -657,10 +666,10 @@
         year--;
 
         /* Gregorian cycles */
-        cycles = (int)((m / (Time64_T) days_in_gregorian_cycle) + 1);
+        cycles = (m / (Time64_T) days_in_gregorian_cycle) + 1;
         if( cycles ) {
-            m -= (cycles * (Time64_T) days_in_gregorian_cycle);
-            year += (cycles * years_in_gregorian_cycle);
+            m -= cycles * (Time64_T) days_in_gregorian_cycle;
+            year += cycles * years_in_gregorian_cycle;
         }
 
         /* Years */
@@ -680,7 +689,12 @@
         m += (Time64_T) days_in_month[leap][v_tm_mon];
     }
 
-    p->tm_year = year;
+#   ifdef USE_TM64
+      p->tm_year = year;
+#   else
+      p->tm_year = (int)year;
+#   endif
+
     if( p->tm_year != year ) {
 #ifdef EOVERFLOW
         errno = EOVERFLOW;
@@ -696,12 +710,14 @@
     p->tm_hour = v_tm_hour;
     p->tm_mon  = v_tm_mon;
     p->tm_wday = v_tm_wday;
+    
+    assert(check_tm(p));
 
     return p;
 }
 
 
-struct TM *localtime64_r (const Time64_T *ytime, struct TM *local_tm)
+struct TM *localtime64_r (const Time64_T *time, struct TM *local_tm)
 {
     time_t safe_time;
     struct tm safe_date;
@@ -712,20 +728,21 @@
     assert(local_tm != NULL);
 
     /* Use the system localtime() if time_t is small enough */
-    if( SHOULD_USE_SYSTEM_LOCALTIME(*ytime) ) {
-        safe_time = (time_t)*ytime;
+    if( SHOULD_USE_SYSTEM_LOCALTIME(*time) ) {
+        safe_time = (time_t)*time;
 
-        TIME64_TRACE1("Using system localtime for %lld\n", *ytime);
+        TIME64_TRACE1("Using system localtime for %"PRId64"\n", *time);
 
         LOCALTIME_R(&safe_time, &safe_date);
 
         copy_tm_to_TM64(&safe_date, local_tm);
+        assert(check_tm(local_tm));
 
         return local_tm;
     }
 
-    if( gmtime64_r(ytime, &gm_tm) == NULL ) {
-        TIME64_TRACE1("gmtime64_r returned null for %lld\n", *ytime);
+    if( gmtime64_r(time, &gm_tm) == NULL ) {
+        TIME64_TRACE1("gmtime64_r returned null for %"PRId64"\n", *time);
         return NULL;
     }
 
@@ -735,7 +752,7 @@
         gm_tm.tm_year < (1970 - 1900)
        )
     {
-        TIME64_TRACE1("Mapping tm_year %lld to safe_year\n", 
(Year)gm_tm.tm_year);
+        TIME64_TRACE1("Mapping tm_year %"PRId64" to safe_year\n", 
(Year)gm_tm.tm_year);
         gm_tm.tm_year = safe_year((Year)(gm_tm.tm_year + 1900)) - 1900;
     }
 
@@ -747,9 +764,14 @@
 
     copy_tm_to_TM64(&safe_date, local_tm);
 
-    local_tm->tm_year = orig_year;
+#   ifdef USE_TM64
+      local_tm->tm_year = orig_year;
+#   else
+      local_tm->tm_year = (int)orig_year;
+#   endif
+
     if( local_tm->tm_year != orig_year ) {
-        TIME64_TRACE2("tm_year overflow: tm_year %lld, orig_year %lld\n",
+        TIME64_TRACE2("tm_year overflow: tm_year %"PRId64", orig_year 
%"PRId64"\n",
               (Year)local_tm->tm_year, (Year)orig_year);
 
 #ifdef EOVERFLOW
@@ -775,7 +797,7 @@
         local_tm->tm_year++;
     }
 
-    /* GMT is Jan 1st, xx01 year, but localtime is still Dec 31st
+    /* GMT is Jan 1st, xx01 year, but localtime is still Dec 31st 
        in a non-leap xx00.  There is one point in the cycle
        we can't account for which the safe xx00 year is a leap
        year.  So we need to correct for Dec 31st coming out as
@@ -784,11 +806,13 @@
     if( !IS_LEAP(local_tm->tm_year) && local_tm->tm_yday == 365 )
         local_tm->tm_yday--;
 
+    assert(check_tm(local_tm));
+    
     return local_tm;
 }
 
 
-int valid_tm_wday( const struct TM* date ) {
+static int valid_tm_wday( const struct TM* date ) {
     if( 0 <= date->tm_wday && date->tm_wday <= 6 )
         return 1;
     else
@@ -795,7 +819,7 @@
         return 0;
 }
 
-int valid_tm_mon( const struct TM* date ) {
+static int valid_tm_mon( const struct TM* date ) {
     if( 0 <= date->tm_mon && date->tm_mon <= 11 )
         return 1;
     else
@@ -820,23 +844,22 @@
 }
 
 
-char *ctime64_r( const Time64_T* ytime, char* result ) {
+char *ctime64_r( const Time64_T* time, char* result ) {
     struct TM date;
-    memset(&date, 0, sizeof(struct TM));
 
-    localtime64_r(ytime, &date );
+    localtime64_r( time, &date );
     return asctime64_r( &date, result );
 }
 
 
 /* Non-thread safe versions of the above */
-struct TM *localtime64(const Time64_T *ytime) {
+struct TM *localtime64(const Time64_T *time) {
     tzset();
-    return localtime64_r(ytime, &Static_Return_Date);
+    return localtime64_r(time, &Static_Return_Date);
 }
 
-struct TM *gmtime64(const Time64_T *ytime) {
-    return gmtime64_r(ytime, &Static_Return_Date);
+struct TM *gmtime64(const Time64_T *time) {
+    return gmtime64_r(time, &Static_Return_Date);
 }
 
 char *asctime64( const struct TM* date ) {
@@ -843,7 +866,7 @@
     return asctime64_r( date, Static_Return_String );
 }
 
-char *ctime64( const Time64_T* ytime ) {
+char *ctime64( const Time64_T* time ) {
     tzset();
-    return asctime64(localtime64(ytime));
+    return asctime64(localtime64(time));
 }

Modified: brlcad/branches/opencl/src/libbu/y2038/time64.h
===================================================================
--- brlcad/branches/opencl/src/libbu/y2038/time64.h     2020-06-08 02:05:52 UTC 
(rev 76063)
+++ brlcad/branches/opencl/src/libbu/y2038/time64.h     2020-06-08 08:12:36 UTC 
(rev 76064)
@@ -1,31 +1,26 @@
 #ifndef TIME64_H
 #    define TIME64_H
 
-#include "common.h"
-
-#ifndef Y2038_EXPORT
-#  if defined(Y2038_DLL_EXPORTS) && defined(Y2038_DLL_IMPORTS)
-#    error "Only Y2038_DLL_EXPORTS or Y2038_DLL_IMPORTS can be defined, not 
both."
-#  elif defined(STATIC_BUILD)
-#    define Y2038_EXPORT
-#  elif defined(Y2038_DLL_EXPORTS)
-#    define Y2038_EXPORT __declspec(dllexport)
-#  elif defined(Y2038_DLL_IMPORTS)
-#    define Y2038_EXPORT __declspec(dllimport)
-#  else
-#    define Y2038_EXPORT
-#  endif
-#endif
-
 #include <time.h>
 #include "time64_config.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-
 /* Set our custom types */
-typedef INT_64_T       Time64_T;
-typedef INT_64_T       Year;
+typedef INT_64_T        Int64;
+typedef Int64           Time64_T;
+typedef Int64           Year;
 
+#ifndef PRId64
+# if (__WORDSIZE == 64) && !defined(__APPLE__)
+#  define PRId64 "ld"
+# else
+#  define PRId64 "lld"
+# endif
+#endif
+
 /* A copy of the tm struct but with a 64 bit year */
 struct TM64 {
         int     tm_sec;
@@ -43,32 +38,34 @@
 #endif
 
 #ifdef HAS_TM_TM_ZONE
-        char    *tm_zone;
+        const char *tm_zone;
 #endif
 };
 
+
 /* Decide which tm struct to use */
 #ifdef USE_TM64
 #define TM      TM64
 #else
 #define TM      tm
-#endif
+#endif   
 
+
 /* Declare public functions */
-Y2038_EXPORT struct TM *gmtime64_r    (const Time64_T *, struct TM *);
-Y2038_EXPORT struct TM *localtime64_r (const Time64_T *, struct TM *);
-Y2038_EXPORT struct TM *gmtime64      (const Time64_T *);
-Y2038_EXPORT struct TM *localtime64   (const Time64_T *);
+struct TM *gmtime64_r    (const Time64_T *, struct TM *);
+struct TM *localtime64_r (const Time64_T *, struct TM *);
+struct TM *gmtime64      (const Time64_T *);
+struct TM *localtime64   (const Time64_T *);
 
-Y2038_EXPORT char *asctime64          (const struct TM *);
-Y2038_EXPORT char *asctime64_r        (const struct TM *, char *);
+char *asctime64          (const struct TM *);
+char *asctime64_r        (const struct TM *, char *);
 
-Y2038_EXPORT char *ctime64            (const Time64_T*);
-Y2038_EXPORT char *ctime64_r          (const Time64_T*, char*);
+char *ctime64            (const Time64_T*);
+char *ctime64_r          (const Time64_T*, char*);
 
-Y2038_EXPORT Time64_T   timegm64      (const struct TM *);
-Y2038_EXPORT Time64_T   mktime64      (struct TM *);
-Y2038_EXPORT Time64_T   timelocal64   (struct TM *);
+Time64_T   timegm64      (const struct TM *);
+Time64_T   mktime64      (struct TM *);
+Time64_T   timelocal64   (struct TM *);
 
 
 /* Not everyone has gm/localtime_r(), provide a replacement */
@@ -86,10 +83,13 @@
 
 /* Use a different asctime format depending on how big the year is */
 #ifdef USE_TM64
-    #define TM64_ASCTIME_FORMAT "%.3s %.3s%3d %.2d:%.2d:%.2d %lld\n"
+    #define TM64_ASCTIME_FORMAT "%.3s %.3s%3d %.2d:%.2d:%.2d %"PRId64"\n"
 #else
     #define TM64_ASCTIME_FORMAT "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n"
 #endif
 
+#ifdef __cplusplus
+  };
+#endif
 
 #endif

Modified: brlcad/branches/opencl/src/libbu/y2038/time64_config.h
===================================================================
--- brlcad/branches/opencl/src/libbu/y2038/time64_config.h      2020-06-08 
02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/libbu/y2038/time64_config.h      2020-06-08 
08:12:36 UTC (rev 76064)
@@ -4,6 +4,8 @@
    Sensible defaults provided.
 */
 
+#include <stdint.h>   /* If your system does not have stdint.h or does not 
define int64_t, you can use 'long long' instead, */
+                      /* but then make sure that 'long long' is indeed a 
64-bit signed integer on your platform. */
 
 #ifndef TIME64_CONFIG_H
 #    define TIME64_CONFIG_H
@@ -18,8 +20,6 @@
 /* INT_64_T
    A 64 bit integer type to use to store time and others.
    Must be defined.
-
-   MODIFIED: Use BRL-CAD's int64_t
 */
 #define INT_64_T                int64_t
 
@@ -42,12 +42,9 @@
 
    HAS_TIMEGM
    Define if your system has timegm(), a GNU extension.
-
-   MODIFIED: Reduce necessary number of CMake checks by assuming that
-   nothing nonstandard exists.
 */
-/* #define HAS_GMTIME_R */
-/* #define HAS_LOCALTIME_R */
+#define HAS_GMTIME_R
+#define HAS_LOCALTIME_R
 /* #define HAS_TIMEGM */
 
 
@@ -54,15 +51,18 @@
 /* Details of non-standard tm struct elements.
 
    HAS_TM_TM_GMTOFF
-   True if your tm struct has a "tm_gmtoff" element.
+   Defined if your tm struct has a "tm_gmtoff" element.
    A BSD extension.
 
    HAS_TM_TM_ZONE
-   True if your tm struct has a "tm_zone" element.
+   Defined if your tm struct has a "tm_zone" element.
    A BSD extension.
+
+   If you define these symbols Under Linux/glibc, you either need to define 
_BSD_SOURCE before including time.h,
+   or change time64's source code to use names __tm_gmtoff and __tm_zone 
instead of tm_gmtoff and tm_zone.
 */
-/* #define HAS_TM_TM_GMTOFF */
-/* #define HAS_TM_TM_ZONE */
+#define HAS_TM_TM_GMTOFF
+#define HAS_TM_TM_ZONE
 
 
 /* USE_SYSTEM_LOCALTIME
@@ -72,15 +72,10 @@
    Should we use the system functions if the time is inside their range?
    Your system localtime() is probably more accurate, but our gmtime() is
    fast and safe.
-
-   MODIFIED: Never use any system functions so that we don't have to
-   worry about the size of the host time_t.  DO NOT RE-ENABLE ANY OF
-   THESE: the limits of the system functions have not been hooked into
-   BRL-CAD's build system and may be incorrect on some platforms.
 */
-/* #define USE_SYSTEM_LOCALTIME */
+#define USE_SYSTEM_LOCALTIME
 /* #define USE_SYSTEM_GMTIME */
-/* #define USE_SYSTEM_MKTIME */
+#define USE_SYSTEM_MKTIME
 /* #define USE_SYSTEM_TIMEGM */
 
 #endif /* TIME64_CONFIG_H */

Modified: brlcad/branches/opencl/src/libbu/y2038/time64_limits.h
===================================================================
--- brlcad/branches/opencl/src/libbu/y2038/time64_limits.h      2020-06-08 
02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/libbu/y2038/time64_limits.h      2020-06-08 
08:12:36 UTC (rev 76064)
@@ -1,6 +1,7 @@
-/*
+/* This header file is to be considered private to time64.c, so do not include 
it from your code.
+
    Maximum and minimum inputs your system's respective time functions
-   can correctly handle.  time64.h will use your system functions if
+   can correctly handle.  time64 will use your system functions if
    the input falls inside these ranges and corresponding USE_SYSTEM_*
    constant is defined.
 */
@@ -16,12 +17,80 @@
 #define SYSTEM_GMTIME_MAX        2147483647
 #define SYSTEM_GMTIME_MIN       -2147483647-1
 
-/* MODIFIED: Moved max/min for mktime() to time64.c to avoid having to
-   initialize it with system-dependent field ordering.
-*/
+/* Max/min for mktime() */
+static const struct tm SYSTEM_MKTIME_MAX = {
+    7,
+    14,
+    19,
+    18,
+    0,
+    138,
+    1,
+    17,
+    0
+#ifdef HAS_TM_TM_GMTOFF
+    ,-28800
+#endif
+#ifdef HAS_TM_TM_ZONE
+    ,"PST"
+#endif
+};
 
-/* MODIFIED: Removed SYSTEM_TIMEGM_MAX/MIN since they are not used
-   anywhere
-*/
+static const struct tm SYSTEM_MKTIME_MIN = {
+    52,
+    45,
+    12,
+    13,
+    11,
+    1,
+    5,
+    346,
+    0
+#ifdef HAS_TM_TM_GMTOFF
+    ,-28800
+#endif
+#ifdef HAS_TM_TM_ZONE
+    ,"PST"
+#endif
+};
 
+/* Max/min for timegm() */
+#ifdef HAS_TIMEGM
+static const struct tm SYSTEM_TIMEGM_MAX = {
+    7,
+    14,
+    3,
+    19,
+    0,
+    138,
+    2,
+    18,
+    0
+    #ifdef HAS_TM_TM_GMTOFF
+        ,0
+    #endif
+    #ifdef HAS_TM_TM_ZONE
+        ,"UTC"
+    #endif
+};
+
+static const struct tm SYSTEM_TIMEGM_MIN = {
+    52,
+    45,
+    20,
+    13,
+    11,
+    1,
+    5,
+    346,
+    0
+    #ifdef HAS_TM_TM_GMTOFF
+        ,0
+    #endif
+    #ifdef HAS_TM_TM_ZONE
+        ,"UTC"
+    #endif
+};
+#endif /* HAS_TIMEGM */
+
 #endif /* TIME64_LIMITS_H */

Modified: brlcad/branches/opencl/src/libgcv/plugins/fastgen4/fastgen4_write.cpp
===================================================================
--- brlcad/branches/opencl/src/libgcv/plugins/fastgen4/fastgen4_write.cpp       
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/libgcv/plugins/fastgen4/fastgen4_write.cpp       
2020-06-08 08:12:36 UTC (rev 76064)
@@ -38,7 +38,7 @@
 #include "gcv/api.h"
 #include "gcv/util.h"
 
-namespace
+namespace fastgen4_write
 {
 
 
@@ -2580,7 +2580,7 @@
 extern "C"
 {
     struct gcv_filter gcv_conv_fastgen4_write =
-    {"FASTGEN4 Writer", GCV_FILTER_WRITE, BU_MIME_MODEL_VND_FASTGEN, NULL, 
NULL, NULL, fastgen4_write};
+    {"FASTGEN4 Writer", GCV_FILTER_WRITE, BU_MIME_MODEL_VND_FASTGEN, NULL, 
NULL, NULL, fastgen4_write::fastgen4_write};
 }
 
 

Modified: brlcad/branches/opencl/src/libgcv/plugins/rhino/rhino_read.cpp
===================================================================
--- brlcad/branches/opencl/src/libgcv/plugins/rhino/rhino_read.cpp      
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/libgcv/plugins/rhino/rhino_read.cpp      
2020-06-08 08:12:36 UTC (rev 76064)
@@ -42,7 +42,7 @@
 #include <stdexcept>
 
 
-namespace
+namespace rhino_read
 {
 
 
@@ -928,7 +928,7 @@
 
 extern "C"
 {
-    extern const gcv_plugin gcv_plugin_info_s = {filters};
+    extern const gcv_plugin gcv_plugin_info_s = {rhino_read::filters};
     GCV_EXPORT const struct gcv_plugin *
     gcv_plugin_info()
     {

Modified: brlcad/branches/opencl/src/libged/simulate/rt_collision_algorithm.cpp
===================================================================
--- brlcad/branches/opencl/src/libged/simulate/rt_collision_algorithm.cpp       
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/libged/simulate/rt_collision_algorithm.cpp       
2020-06-08 08:12:36 UTC (rev 76064)
@@ -41,7 +41,7 @@
 #include <cmath>
 
 
-namespace
+namespace rt_collision_algorithm
 {
 
 
@@ -300,13 +300,13 @@
 
     result->setPersistentManifold(m_manifold);
 
-    if (!use_persistent_contacts)
+    if (!rt_collision_algorithm::use_persistent_contacts)
        m_manifold->clearManifold();
 
-    calculate_contact_points(*result, *body_a_wrap, *body_b_wrap, 
m_rt_instance,
+    rt_collision_algorithm::calculate_contact_points(*result, *body_a_wrap, 
*body_b_wrap, m_rt_instance,
                             m_grid_radius, m_debug_draw);
 
-    if (use_persistent_contacts && m_owns_manifold)
+    if (rt_collision_algorithm::use_persistent_contacts && m_owns_manifold)
        result->refreshContactPoints();
 }
 

Modified: brlcad/branches/opencl/src/librt/primitives/ebm/ebm.c
===================================================================
--- brlcad/branches/opencl/src/librt/primitives/ebm/ebm.c       2020-06-08 
02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/librt/primitives/ebm/ebm.c       2020-06-08 
08:12:36 UTC (rev 76064)
@@ -122,7 +122,7 @@
     cl_double tallness;                /**< @brief Z dimension (mm) */
     cl_uint xdim;              /**< @brief X dimension (w cells) */
     cl_uint ydim;              /**< @brief Y dimension (n cells) */
-    cl_uchar apbuf[];
+    cl_uchar apbuf[9999]; /* !!! */
 };
 
 size_t

Modified: brlcad/branches/opencl/src/librt/reduce_db.cpp
===================================================================
--- brlcad/branches/opencl/src/librt/reduce_db.cpp      2020-06-08 02:05:52 UTC 
(rev 76063)
+++ brlcad/branches/opencl/src/librt/reduce_db.cpp      2020-06-08 08:12:36 UTC 
(rev 76064)
@@ -40,7 +40,7 @@
 #include <string>
 
 
-namespace
+namespace reduce_db
 {
 
 
@@ -139,7 +139,7 @@
 }
 
 
-namespace
+namespace reduce_db
 {
 
 
@@ -523,7 +523,7 @@
     {
        RT_CK_DBI(db);
 
-       remove_dead_references(*db);
+       reduce_db::remove_dead_references(*db);
 
        std::set<std::string> preserved_attributes;
        std::set<directory *> preserved_combs;
@@ -542,7 +542,7 @@
            }
        }
 
-       Hierarchy hierarchy(*db, preserved_attributes, preserved_combs);
+       reduce_db::Hierarchy hierarchy(*db, preserved_attributes, 
preserved_combs);
        hierarchy.merge();
        hierarchy.write();
     }

Modified: brlcad/branches/opencl/src/other/gdal/port/cpl_config.h.in
===================================================================
--- brlcad/branches/opencl/src/other/gdal/port/cpl_config.h.in  2020-06-08 
02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/other/gdal/port/cpl_config.h.in  2020-06-08 
08:12:36 UTC (rev 76064)
@@ -307,3 +307,5 @@
 
 /* Define to 1 if you have the `std::isnan' function. */
 #cmakedefine HAVE_STD_IS_NAN 1
+
+#cmakedefine HAVE_XLOCALE_H 1

Modified: brlcad/branches/opencl/src/other/openNURBS/opennurbs_archive.cpp
===================================================================
--- brlcad/branches/opencl/src/other/openNURBS/opennurbs_archive.cpp    
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/other/openNURBS/opennurbs_archive.cpp    
2020-06-08 08:12:36 UTC (rev 76064)
@@ -581,13 +581,13 @@
 bool
 ON_BinaryArchive::ReadMode() const
 {
-  return (m_mode & ON::read) ? true : false;
+  return (m_mode & ON::on_read) ? true : false;
 }
 
 bool
 ON_BinaryArchive::WriteMode() const
 {
-  return (m_mode & ON::write) ? true : false;
+  return (m_mode & ON::on_write) ? true : false;
 }
 
 bool

Modified: brlcad/branches/opencl/src/other/openNURBS/opennurbs_defines.cpp
===================================================================
--- brlcad/branches/opencl/src/other/openNURBS/opennurbs_defines.cpp    
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/other/openNURBS/opennurbs_defines.cpp    
2020-06-08 08:12:36 UTC (rev 76064)
@@ -1694,10 +1694,10 @@
 ON::archive_mode ON::ArchiveMode(int i)
 {
   // convert integer to endian enum
-  archive_mode a = read;
+  archive_mode a = on_read;
   switch(i) {
-  case read:      a = read; break;
-  case write:     a = write; break;
+  case on_read:      a = on_read; break;
+  case on_write:     a = on_write; break;
   case readwrite: a = readwrite; break;
   case read3dm:   a = read3dm; break;
   case write3dm:  a = write3dm; break;

Modified: brlcad/branches/opencl/src/other/openNURBS/opennurbs_defines.h
===================================================================
--- brlcad/branches/opencl/src/other/openNURBS/opennurbs_defines.h      
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/other/openNURBS/opennurbs_defines.h      
2020-06-08 08:12:36 UTC (rev 76064)
@@ -803,8 +803,8 @@
   enum archive_mode
   {
     unknown_archive_mode = 0,
-    read      = 1, // all read modes have bit 0x0001 set
-    write     = 2, // all write modes have bit 0x0002 set
+    on_read   = 1, // all read modes have bit 0x0001 set
+    on_write  = 2, // all write modes have bit 0x0002 set
     readwrite = 3,
     read3dm   = 5,
     write3dm  = 6

Modified: brlcad/branches/opencl/src/other/openNURBS/opennurbs_zlib.cpp
===================================================================
--- brlcad/branches/opencl/src/other/openNURBS/opennurbs_zlib.cpp       
2020-06-08 02:05:52 UTC (rev 76063)
+++ brlcad/branches/opencl/src/other/openNURBS/opennurbs_zlib.cpp       
2020-06-08 08:12:36 UTC (rev 76064)
@@ -525,11 +525,11 @@
   // inflateInit() and deflateInit() are in zlib 1.3.3
   bool rc = false;
   if ( WriteMode() ) {
-    rc = ( m_zlib.mode == ON::write ) ? true : false;
+    rc = ( m_zlib.mode == ON::on_write ) ? true : false;
     if ( !rc ) {
       CompressionEnd();
       if ( Z_OK == deflateInit( &m_zlib.strm, Z_BEST_COMPRESSION ) ) {
-        m_zlib.mode = ON::write;
+        m_zlib.mode = ON::on_write;
         rc = true;
       }
       else {
@@ -538,11 +538,11 @@
     }
   }
   else if ( ReadMode() ) {
-    rc = ( m_zlib.mode == ON::read ) ? true : false;
+    rc = ( m_zlib.mode == ON::on_read ) ? true : false;
     if ( !rc ) {
       CompressionEnd();
       if ( Z_OK == inflateInit( &m_zlib.strm ) ) {
-        m_zlib.mode = ON::read;
+        m_zlib.mode = ON::on_read;
         rc = true;
       }
       else {
@@ -560,11 +560,11 @@
 {
   // inflateEnd() and deflateEnd() are in zlib 1.3.3
   switch ( m_zlib.mode ) {
-  case ON::read:
+  case ON::on_read:
   case ON::read3dm:
     inflateEnd(&m_zlib.strm);
     break;
-  case ON::write:
+  case ON::on_write:
   case ON::write3dm:
     deflateEnd(&m_zlib.strm);
     break;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to