Skip to content

Commit 739ae83

Browse files
committed
moved linux specific code
1 parent 42fa2da commit 739ae83

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

libc/src/time/linux/localtime_utils.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313
namespace LIBC_NAMESPACE_DECL {
1414
namespace localtime_utils {
1515

16+
void release_file(ErrorOr<File *> error_or_file) {
17+
file_usage = 0;
18+
error_or_file.value()->close();
19+
}
20+
21+
ErrorOr<File *> acquire_file(char *filename) {
22+
while (1) {
23+
if (file_usage == 0) {
24+
file_usage = 1;
25+
break;
26+
}
27+
}
28+
29+
return LIBC_NAMESPACE::openfile(filename, "rb");
30+
}
31+
1632
timezone::tzset *get_localtime(struct tm *tm) {
1733
(void)tm;
1834
return nullptr;

libc/src/time/linux/localtime_utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include "src/errno/libc_errno.h"
1515
#include "src/time/linux/timezone.h"
1616

17+
LIBC_INLINE volatile int file_usage;
18+
1719
namespace LIBC_NAMESPACE_DECL {
1820
namespace localtime_utils {
1921

libc/src/time/time_utils.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,6 @@ static int64_t computeRemainingYears(int64_t daysPerYears,
129129
return years;
130130
}
131131

132-
void release_file(ErrorOr<File *> error_or_file) {
133-
file_usage = 0;
134-
error_or_file.value()->close();
135-
}
136-
137-
ErrorOr<File *> acquire_file(char *filename) {
138-
while (1) {
139-
if (file_usage == 0) {
140-
file_usage = 1;
141-
break;
142-
}
143-
}
144-
145-
return LIBC_NAMESPACE::openfile(filename, "rb");
146-
}
147-
148132
char *get_env_var(const char *input) {
149133
for (char **env = environ; *env != NULL; ++env) {
150134
char *env_var = *env;

libc/src/time/time_utils.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,13 @@ namespace time_utils {
3535
// you must call update_from_seconds for that.
3636
cpp::optional<time_t> mktime_internal(const tm *tm_out);
3737

38-
LIBC_INLINE volatile int file_usage;
39-
4038
// Update the "tm" structure's year, month, etc. members from seconds.
4139
// "total_seconds" is the number of seconds since January 1st, 1970.
4240
extern int calculate_dst(struct tm *tm);
4341
extern void set_dst(struct tm *tm);
4442
extern int64_t update_from_seconds(int64_t total_seconds, struct tm *tm, bool local);
4543
extern timezone::tzset *get_localtime(struct tm *tm);
4644
extern int64_t update_from_seconds(int64_t total_seconds, struct tm *tm);
47-
extern ErrorOr<File *> acquire_file(char *filename);
48-
extern void release_file(ErrorOr<File *> error_or_file);
4945
extern unsigned char is_dst(struct tm *tm);
5046

5147
#ifdef LIBC_TARGET_OS_IS_LINUX

0 commit comments

Comments
 (0)