Fixed building on SmartOS

timeradd is missing on Solaris 10, but is present as a macro in
<sys/time.h> on SmartOS, illumos, and likely Solaris 11.
This commit is contained in:
Mike Gerdts 2018-02-16 22:34:41 +00:00 committed by Daniele Varrazzo
parent 8f18681723
commit 317917866e
2 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,7 @@
/* solaris_support.c - emulate functions missing on Solaris /* solaris_support.c - emulate functions missing on Solaris
* *
* Copyright (C) 2017 My Karlsson <mk@acc.umu.se> * Copyright (C) 2017 My Karlsson <mk@acc.umu.se>
* Copyright (c) 2018, Joyent, Inc.
* *
* This file is part of psycopg. * This file is part of psycopg.
* *
@ -28,7 +29,8 @@
#include "psycopg/solaris_support.h" #include "psycopg/solaris_support.h"
#if defined(__sun) && defined(__SVR4) #if defined(__sun) && defined(__SVR4)
/* timeradd is missing on Solaris */ /* timeradd is missing on Solaris 10 */
#ifndef timeradd
void void
timeradd(struct timeval *a, struct timeval *b, struct timeval *c) timeradd(struct timeval *a, struct timeval *b, struct timeval *c)
{ {
@ -51,4 +53,5 @@ timersub(struct timeval *a, struct timeval *b, struct timeval *c)
c->tv_sec -= 1; c->tv_sec -= 1;
} }
} }
#endif /* timeradd */
#endif /* defined(__sun) && defined(__SVR4) */ #endif /* defined(__sun) && defined(__SVR4) */

View File

@ -1,6 +1,7 @@
/* solaris_support.h - definitions for solaris_support.c /* solaris_support.h - definitions for solaris_support.c
* *
* Copyright (C) 2017 My Karlsson <mk@acc.umu.se> * Copyright (C) 2017 My Karlsson <mk@acc.umu.se>
* Copyright (c) 2018, Joyent, Inc.
* *
* This file is part of psycopg. * This file is part of psycopg.
* *
@ -30,8 +31,10 @@
#if defined(__sun) && defined(__SVR4) #if defined(__sun) && defined(__SVR4)
#include <sys/time.h> #include <sys/time.h>
#ifndef timeradd
extern HIDDEN void timeradd(struct timeval *a, struct timeval *b, struct timeval *c); extern HIDDEN void timeradd(struct timeval *a, struct timeval *b, struct timeval *c);
extern HIDDEN void timersub(struct timeval *a, struct timeval *b, struct timeval *c); extern HIDDEN void timersub(struct timeval *a, struct timeval *b, struct timeval *c);
#endif #endif
#endif
#endif /* !defined(PSYCOPG_SOLARIS_SUPPORT_H) */ #endif /* !defined(PSYCOPG_SOLARIS_SUPPORT_H) */