-
Notifications
You must be signed in to change notification settings - Fork 683
Fix system call related date builtin functions #873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* Copyright 2016 Samsung Electronics Co., Ltd. | ||
* Copyright 2016 University of Szeged | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
#ifndef JERRY_LIBC_TIME_H | ||
#define JERRY_LIBC_TIME_H | ||
|
||
#ifdef __cplusplus | ||
# define EXTERN_C "C" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is not this will be a symbol clash? I think there is a { } based solution for that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This worked fine for me. Could you be more specific? BTW, this is used in every jerry-libc header. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @zherczeg here. It would be better to use the more traditional #ifdef __cplusplus
extern "C" {
#endif
// header main content here
#ifdef __cplusplus
}
#endif approach. The issue is that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I'll change it everywhere and add it in a separate commit, but part of this PR. |
||
#else /* !__cplusplus */ | ||
# define EXTERN_C | ||
#endif /* !__cplusplus */ | ||
|
||
/** | ||
* Time value structure | ||
*/ | ||
struct _timeval | ||
{ | ||
unsigned long tv_sec; /**< seconds */ | ||
unsigned long tv_usec; /**< microseconds */ | ||
}; | ||
|
||
/** | ||
* Timezone structure | ||
*/ | ||
struct timezone | ||
{ | ||
int tz_minuteswest; /**< minutes west of Greenwich */ | ||
int tz_dsttime; /**< type of DST correction */ | ||
}; | ||
|
||
extern EXTERN_C int gettimeofday (void *tp, void *tzp); | ||
|
||
#endif /* !JERRY_LIBC_TIME_H */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd. | ||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd. | ||
* Copyright 2016 University of Szeged. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -28,6 +29,7 @@ | |
#include <sys/resource.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <time.h> | ||
|
||
#include "jerry-libc-defs.h" | ||
|
||
|
@@ -384,3 +386,14 @@ fwrite (const void *ptr, /**< data to write */ | |
return bytes_written / size; | ||
} /* fwrite */ | ||
|
||
/** | ||
* This function can get the time as well as a timezone. | ||
* | ||
* @return 0 if success, -1 otherwise | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return value description? |
||
int | ||
gettimeofday (void *tp, /**< struct timeval */ | ||
void *tzp) /**< struct timezone */ | ||
{ | ||
return (int) syscall_2 (__NR_gettimeofday, (long int) tp, (long int) tzp); | ||
} /* gettimeofday */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the <time.h> include should be inside the ifndef. It is not needed otherwise.