Repository: pandas-dev/pandas
File: pandas/_libs/include/pandas/vendored/numpy/datetime/np_datetime.h (C/C++)

Code before:
/*

Copyright (c) 2016, PyData Development Team
All rights reserved.

Distributed under the terms of the BSD Simplified License.

The full license is in the LICENSE file, distributed with this software.

Copyright (c) 2005-2011, NumPy Developers
All rights reserved.

This file is derived from NumPy 1.7. See NUMPY_LICENSE.txt

*/

#pragma once

#ifndef NPY_NO_DEPRECATED_API
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#endif // NPY_NO_DEPRECATED_API

#if defined(_WIN32)
#ifndef ENABLE_INTSAFE_SIGNED_FUNCTIONS
#define ENABLE_INTSAFE_SIGNED_FUNCTIONS
#endif
#include <intsafe.h>
#define checked_int64_add(a, b, res) LongLongAdd(a, b, res)
#define checked_int64_sub(a, b, res) LongLongSub(a, b, res)
#define checked_int64_mul(a, b, res) LongLongMult(a, b, res)
#else
#if defined __has_builtin
#if __has_builtin(__builtin_add_overflow)
#define checked_int64_add(a, b, res) __builtin_add_overflow(a, b, res)
#define checked_int64_sub(a, b, res) __builtin_sub_overflow(a, b, res)
#define checked_int64_mul(a, b, res) __builtin_mul_overflow(a, b, res)
#else
_Static_assert(0,
               "Overflow checking not detected; please try a newer compiler");
#endif
// __has_builtin was added in gcc 10, but our muslinux_1_1 build environment
// only has gcc-9.3, so fall back to __GNUC__ macro as long as we have that
#elif __GNUC__ > 7
#define checked_int64_add(a, b, res) __builtin_add_overflow(a, b, res)
#define checked_int64_sub(a, b, res) __builtin_sub_overflow(a, b, res)
#define checked_int64_mul(a, b, res) __builtin_mul_overflow(a, b, res)
#else
_Static_assert(0, "__has_builtin not detected; please try a newer compiler");

Review comment (suggestion):
Its probably best to move these to the `include/pandas/portable.h` header

Code after:
/*

Copyright (c) 2016, PyData Development Team
All rights reserved.

Distributed under the terms of the BSD Simplified License.

The full license is in the LICENSE file, distributed with this software.

Copyright (c) 2005-2011, NumPy Developers
All rights reserved.

This file is derived from NumPy 1.7. See NUMPY_LICENSE.txt

*/

#pragma once

#ifndef NPY_NO_DEPRECATED_API
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#endif // NPY_NO_DEPRECATED_API

#include <numpy/ndarraytypes.h>

typedef struct {
  npy_int64 days;
  npy_int32 hrs, min, sec, ms, us, ns, seconds, microseconds, nanoseconds;
} pandas_timedeltastruct;

static const npy_datetimestruct _AS_MIN_DTS = {1969, 12,     31,     23,    59,
                                               50,   776627, 963145, 224193};
static const npy_datetimestruct _FS_MIN_DTS = {1969, 12,     31,     21,    26,
                                               16,   627963, 145224, 193000};
static const npy_datetimestruct _PS_MIN_DTS = {1969, 9,      16,     5, 57,
                                               7,    963145, 224193, 0};
static const npy_datetimestruct _NS_MIN_DTS = {1677, 9,      21,     0, 12,
                                               43,   145224, 193000, 0};
static const npy_datetimestruct _US_MIN_DTS = {-290308, 12,     21, 19, 59,
                                               05,      224193, 0,  0};
static const npy_datetimestruct _MS_MIN_DTS = {-292275055, 5,      16, 16, 47,
                                               4,          193000, 0,  0};
static const npy_datetimestruct _S_MIN_DTS = {
    -292277022657, 1, 27, 8, 29, 53, 0, 0, 0};
static const npy_datetimestruct _M_MIN_DTS = {
    -17536621475646, 5, 4, 5, 53, 0, 0, 0, 0};

static const npy_datetimestruct _AS_MAX_DTS = {1970, 1,      1,     0,     0,
                                               9,    223372, 36854, 775807};