mirror of
https://github.com/apache/nuttx.git
synced 2026-10-10 07:40:27 +00:00
libs/libc/time: Add tzset() for builds without time zones.
POSIX requires tzset(), but NuttX declared and defined it only with CONFIG_LIBC_LOCALTIME, so programs that call it do not build without that option. Without CONFIG_LIBC_LOCALTIME there are no time zones and local time is UTC, so tzset() has nothing to do. Declare tzset() always, and add an empty one for builds without CONFIG_LIBC_LOCALTIME. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
This commit is contained in:
parent
7942d18fd5
commit
314348cafe
4 changed files with 48 additions and 4 deletions
|
|
@ -237,9 +237,7 @@ int clock_nanosleep(clockid_t clockid, int flags,
|
|||
FAR struct timespec *rmtp);
|
||||
int nanosleep(FAR const struct timespec *rqtp, FAR struct timespec *rmtp);
|
||||
|
||||
#ifdef CONFIG_LIBC_LOCALTIME
|
||||
void tzset(void);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ set(SRCS
|
|||
if(CONFIG_LIBC_LOCALTIME)
|
||||
list(APPEND SRCS lib_localtime.c)
|
||||
else()
|
||||
list(APPEND SRCS lib_timegm.c lib_gmtime.c lib_gmtimer.c)
|
||||
list(APPEND SRCS lib_timegm.c lib_gmtime.c lib_gmtimer.c lib_tzset.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ALLOW_MIT_COMPONENTS)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ CSRCS += lib_gethrtime.c
|
|||
ifdef CONFIG_LIBC_LOCALTIME
|
||||
CSRCS += lib_localtime.c
|
||||
else
|
||||
CSRCS += lib_timegm.c lib_gmtime.c lib_gmtimer.c
|
||||
CSRCS += lib_timegm.c lib_gmtime.c lib_gmtimer.c lib_tzset.c
|
||||
endif
|
||||
|
||||
ifdef CONFIG_ALLOW_MIT_COMPONENTS
|
||||
|
|
|
|||
46
libs/libc/time/lib_tzset.c
Normal file
46
libs/libc/time/lib_tzset.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/****************************************************************************
|
||||
* libs/libc/time/lib_tzset.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <time.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tzset
|
||||
*
|
||||
* Description:
|
||||
* Set up the time zone from the TZ environment variable. Without
|
||||
* CONFIG_LIBC_LOCALTIME there are no time zones (local time is UTC), so
|
||||
* there is nothing to set up. The function exists because POSIX
|
||||
* requires it and portable programs call it.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void tzset(void)
|
||||
{
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue