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:
Corinna Vinschen 2020-05-25 13:50:36 +02:00
parent 57625ac256
commit 49a843b407
3 changed files with 18 additions and 22 deletions

View File

@ -561,7 +561,7 @@ TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $
ifneq "${filter -O%,$(CFLAGS)}" ""
dtable_CFLAGS:=-fcheck-new
localtime_CFLAGS:=-fwrapv -fpermissive
localtime_CFLAGS:=-fwrapv
malloc_CFLAGS:=-O3
sync_CFLAGS:=-O3
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
(cd $(srcdir)/tzcode && \
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$(srcdir) -I$(srcdir)/tzcode -c -o $@ $<

View File

@ -32,13 +32,15 @@
nread = read(fid, up->buf, sizeof up->buf);
if (nread < (ssize_t)tzheadsize) {
int err = nread < 0 ? errno : EINVAL;
@@ -501,6 +501,15 @@
@@ -501,6 +501,17 @@
}
if (close(fid) < 0)
return errno;
+ if (0) {
+ const char *base;
+trydefrules:
+ const char *base = strrchr(name, '/');
+
+ base = strrchr(name, '/');
+ base = base ? base + 1 : name;
+ if (strcmp(base, TZDEFRULES))
+ return errno;
@ -48,7 +50,7 @@
for (stored = 4; stored <= 8; stored *= 2) {
int_fast32_t ttisstdcnt = detzcode(up->tzhead.tzh_ttisstdcnt);
int_fast32_t ttisutcnt = detzcode(up->tzhead.tzh_ttisutcnt);
@@ -1417,6 +1426,8 @@
@@ -1417,6 +1428,8 @@
tzsetlcl(char const *name)
{
struct state *sp = __lclptr;

View File

@ -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
details. */
#include "../winsup.h"
#include "../sync.h"
#include "../include/cygwin/version.h"
#include "winsup.h"
#include "perprocess.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
#define rwlock_wrlock(X) tzset_guard.init("tzset_guard")->acquire()
#define rwlock_unlock(X) tzset_guard.release()
// Convert these NetBSD rwlock ops into SRWLocks
#define rwlock_wrlock(X) AcquireSRWLockExclusive(&tzset_guard)
#define rwlock_unlock(X) ReleaseSRWLockExclusive(&tzset_guard)
// Set these NetBSD-related option #defines appropriately for Cygwin
//#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
#ifdef __cplusplus
extern "C" {
#endif
// Pull these in early to catch any small issues before the real test
#include "private.h"
@ -126,19 +124,15 @@ extern "C" {
*/
#include "localtime.c.patched"
#ifdef __cplusplus
}
#endif
// Don't forget these Cygwin-specific additions from this point to EOF
EXPORT_ALIAS (tzset_unlocked, _tzset_unlocked)
extern "C" long
long
__cygwin_gettzoffset (const struct tm *tmp)
{
#ifdef TM_GMTOFF
if (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS)
return tmp->TM_GMTOFF;
return tmp->TM_GMTOFF;
#endif /* defined TM_GMTOFF */
__tzinfo_type *tz = __gettzinfo ();
/* The sign of this is exactly opposite the envvar TZ. We
@ -148,7 +142,7 @@ __cygwin_gettzoffset (const struct tm *tmp)
return offset;
}
extern "C" const char *
const char *
__cygwin_gettzname (const struct tm *tmp)
{
#ifdef TM_ZONE