Cygwin: convert localtime_wrapper.c to plain C source
That also requires a small tweak to localtime.c.patch, otherwise GCC complains about the position of the 'trydefrules' label. Also, simplify includes. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
57625ac256
commit
49a843b407
@ -561,7 +561,7 @@ TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $
|
|||||||
|
|
||||||
ifneq "${filter -O%,$(CFLAGS)}" ""
|
ifneq "${filter -O%,$(CFLAGS)}" ""
|
||||||
dtable_CFLAGS:=-fcheck-new
|
dtable_CFLAGS:=-fcheck-new
|
||||||
localtime_CFLAGS:=-fwrapv -fpermissive
|
localtime_CFLAGS:=-fwrapv
|
||||||
malloc_CFLAGS:=-O3
|
malloc_CFLAGS:=-O3
|
||||||
sync_CFLAGS:=-O3
|
sync_CFLAGS:=-O3
|
||||||
ifeq ($(target_cpu),i686)
|
ifeq ($(target_cpu),i686)
|
||||||
@ -737,7 +737,7 @@ shared.o: shared_info_magic.h
|
|||||||
localtime.o: $(srcdir)/tzcode/localtime_wrapper.c $(srcdir)/tzcode/localtime.c.patch
|
localtime.o: $(srcdir)/tzcode/localtime_wrapper.c $(srcdir)/tzcode/localtime.c.patch
|
||||||
(cd $(srcdir)/tzcode && \
|
(cd $(srcdir)/tzcode && \
|
||||||
patch -u -o localtime.c.patched localtime.c localtime.c.patch)
|
patch -u -o localtime.c.patched localtime.c localtime.c.patch)
|
||||||
$(CXX) ${CXXFLAGS} ${localtime_CFLAGS} \
|
$(CC) ${COMMON_CFLAGS} ${localtime_CFLAGS} \
|
||||||
-I$(target_builddir)/winsup/cygwin \
|
-I$(target_builddir)/winsup/cygwin \
|
||||||
-I$(srcdir) -I$(srcdir)/tzcode -c -o $@ $<
|
-I$(srcdir) -I$(srcdir)/tzcode -c -o $@ $<
|
||||||
|
|
||||||
|
@ -32,13 +32,15 @@
|
|||||||
nread = read(fid, up->buf, sizeof up->buf);
|
nread = read(fid, up->buf, sizeof up->buf);
|
||||||
if (nread < (ssize_t)tzheadsize) {
|
if (nread < (ssize_t)tzheadsize) {
|
||||||
int err = nread < 0 ? errno : EINVAL;
|
int err = nread < 0 ? errno : EINVAL;
|
||||||
@@ -501,6 +501,15 @@
|
@@ -501,6 +501,17 @@
|
||||||
}
|
}
|
||||||
if (close(fid) < 0)
|
if (close(fid) < 0)
|
||||||
return errno;
|
return errno;
|
||||||
+ if (0) {
|
+ if (0) {
|
||||||
|
+ const char *base;
|
||||||
+trydefrules:
|
+trydefrules:
|
||||||
+ const char *base = strrchr(name, '/');
|
+
|
||||||
|
+ base = strrchr(name, '/');
|
||||||
+ base = base ? base + 1 : name;
|
+ base = base ? base + 1 : name;
|
||||||
+ if (strcmp(base, TZDEFRULES))
|
+ if (strcmp(base, TZDEFRULES))
|
||||||
+ return errno;
|
+ return errno;
|
||||||
@ -48,7 +50,7 @@
|
|||||||
for (stored = 4; stored <= 8; stored *= 2) {
|
for (stored = 4; stored <= 8; stored *= 2) {
|
||||||
int_fast32_t ttisstdcnt = detzcode(up->tzhead.tzh_ttisstdcnt);
|
int_fast32_t ttisstdcnt = detzcode(up->tzhead.tzh_ttisstdcnt);
|
||||||
int_fast32_t ttisutcnt = detzcode(up->tzhead.tzh_ttisutcnt);
|
int_fast32_t ttisutcnt = detzcode(up->tzhead.tzh_ttisutcnt);
|
||||||
@@ -1417,6 +1426,8 @@
|
@@ -1417,6 +1428,8 @@
|
||||||
tzsetlcl(char const *name)
|
tzsetlcl(char const *name)
|
||||||
{
|
{
|
||||||
struct state *sp = __lclptr;
|
struct state *sp = __lclptr;
|
||||||
|
@ -6,16 +6,17 @@ This software is a copyrighted work licensed under the terms of the
|
|||||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||||
details. */
|
details. */
|
||||||
|
|
||||||
#include "../winsup.h"
|
#include "winsup.h"
|
||||||
#include "../sync.h"
|
#include "perprocess.h"
|
||||||
#include "../include/cygwin/version.h"
|
|
||||||
#include "tz_posixrules.h"
|
#include "tz_posixrules.h"
|
||||||
|
#include <cygwin/version.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
static NO_COPY muto tzset_guard;
|
static NO_COPY SRWLOCK tzset_guard = SRWLOCK_INIT;
|
||||||
|
|
||||||
// Convert these NetBSD rwlock ops into Cygwin muto ops
|
// Convert these NetBSD rwlock ops into SRWLocks
|
||||||
#define rwlock_wrlock(X) tzset_guard.init("tzset_guard")->acquire()
|
#define rwlock_wrlock(X) AcquireSRWLockExclusive(&tzset_guard)
|
||||||
#define rwlock_unlock(X) tzset_guard.release()
|
#define rwlock_unlock(X) ReleaseSRWLockExclusive(&tzset_guard)
|
||||||
|
|
||||||
// Set these NetBSD-related option #defines appropriately for Cygwin
|
// Set these NetBSD-related option #defines appropriately for Cygwin
|
||||||
//#define STD_INSPIRED // early-include private.h below does this
|
//#define STD_INSPIRED // early-include private.h below does this
|
||||||
@ -109,9 +110,6 @@ tzgetwintzi (char *wildabbr, char *outbuf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get ready to wrap NetBSD's localtime.c
|
// Get ready to wrap NetBSD's localtime.c
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Pull these in early to catch any small issues before the real test
|
// Pull these in early to catch any small issues before the real test
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
@ -126,19 +124,15 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#include "localtime.c.patched"
|
#include "localtime.c.patched"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Don't forget these Cygwin-specific additions from this point to EOF
|
// Don't forget these Cygwin-specific additions from this point to EOF
|
||||||
EXPORT_ALIAS (tzset_unlocked, _tzset_unlocked)
|
EXPORT_ALIAS (tzset_unlocked, _tzset_unlocked)
|
||||||
|
|
||||||
extern "C" long
|
long
|
||||||
__cygwin_gettzoffset (const struct tm *tmp)
|
__cygwin_gettzoffset (const struct tm *tmp)
|
||||||
{
|
{
|
||||||
#ifdef TM_GMTOFF
|
#ifdef TM_GMTOFF
|
||||||
if (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS)
|
if (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS)
|
||||||
return tmp->TM_GMTOFF;
|
return tmp->TM_GMTOFF;
|
||||||
#endif /* defined TM_GMTOFF */
|
#endif /* defined TM_GMTOFF */
|
||||||
__tzinfo_type *tz = __gettzinfo ();
|
__tzinfo_type *tz = __gettzinfo ();
|
||||||
/* The sign of this is exactly opposite the envvar TZ. We
|
/* The sign of this is exactly opposite the envvar TZ. We
|
||||||
@ -148,7 +142,7 @@ __cygwin_gettzoffset (const struct tm *tmp)
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" const char *
|
const char *
|
||||||
__cygwin_gettzname (const struct tm *tmp)
|
__cygwin_gettzname (const struct tm *tmp)
|
||||||
{
|
{
|
||||||
#ifdef TM_ZONE
|
#ifdef TM_ZONE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user