Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: src/untrusted/nacl/sys_private.c

Issue 1065963002: Add utime implementation to libnacl (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /* 7 /*
8 * This file defines various POSIX-like functions directly using NaCl 8 * This file defines various POSIX-like functions directly using NaCl
9 * syscall trampolines. For normal application use, these are defined 9 * syscall trampolines. For normal application use, these are defined
10 * instead using the IRT function tables. Here we're defining the versions 10 * instead using the IRT function tables. Here we're defining the versions
11 * to be used inside the IRT itself, and in various local tests that do not 11 * to be used inside the IRT itself, and in various local tests that do not
12 * use the IRT. 12 * use the IRT.
13 * 13 *
14 * We define these all in one file so that we can be sure that we get 14 * We define these all in one file so that we can be sure that we get
15 * them all defined here and won't have any stragglers brought in from 15 * them all defined here and won't have any stragglers brought in from
16 * the normal C libraries, where we'd get the IRT-based versions instead. 16 * the normal C libraries, where we'd get the IRT-based versions instead.
17 * Since the first thing in the link (../stubs/crt1.x) forces a reference 17 * Since the first thing in the link (../stubs/crt1.x) forces a reference
18 * to _exit, we can be sure that this file will be brought in first. 18 * to _exit, we can be sure that this file will be brought in first.
19 */ 19 */
20 20
21 #include <errno.h> 21 #include <errno.h>
22 #include <fcntl.h> 22 #include <fcntl.h>
23 #include <sched.h> 23 #include <sched.h>
24 #include <stdarg.h> 24 #include <stdarg.h>
25 #include <stdint.h> 25 #include <stdint.h>
26 #include <sys/mman.h>
27 #include <sys/types.h>
26 #include <time.h> 28 #include <time.h>
27 #include <unistd.h> 29 #include <unistd.h>
28 #include <sys/types.h> 30 #include <utime.h>
29 #include <sys/mman.h>
30 31
31 #include "native_client/src/include/elf32.h" 32 #include "native_client/src/include/elf32.h"
32 #include "native_client/src/untrusted/nacl/getcwd.h" 33 #include "native_client/src/untrusted/nacl/getcwd.h"
33 #include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h" 34 #include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h"
34 35
35 struct dirent; 36 struct dirent;
36 struct stat; 37 struct stat;
37 struct timeval; 38 struct timeval;
38 struct timespec; 39 struct timespec;
39 40
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 246 }
246 247
247 int access(const char *path, int amode) { 248 int access(const char *path, int amode) {
248 return errno_call(NACL_SYSCALL(access)(path, amode)); 249 return errno_call(NACL_SYSCALL(access)(path, amode));
249 } 250 }
250 251
251 int readlink(const char *path, char *buf, int bufsize) { 252 int readlink(const char *path, char *buf, int bufsize) {
252 return errno_value_call(NACL_SYSCALL(readlink)(path, buf, bufsize)); 253 return errno_value_call(NACL_SYSCALL(readlink)(path, buf, bufsize));
253 } 254 }
254 255
256 int utime(const char *path, const struct utimbuf *buf) {
Mark Seaborn 2015/04/07 19:08:43 If utime.c calls utimes(), you don't need this her
Sam Clegg 2015/04/10 21:18:55 Good idea. Done.
257 struct timeval times[2];
258 struct timeval* tv = NULL;
Mark Seaborn 2015/04/07 19:08:43 Use " *" spacing
Sam Clegg 2015/04/10 21:18:55 Acknowledged.
259 if (buf != NULL) {
260 times[0].tv_sec = buf->actime;
261 times[1].tv_sec = buf->modtime;
262 times[0].tv_usec = 0;
263 times[1].tv_usec = 0;
264 tv = times;
265 }
266 return errno_value_call(NACL_SYSCALL(utimes)(path, tv));
267 }
268
255 int utimes(const char *path, const struct timeval times[2]) { 269 int utimes(const char *path, const struct timeval times[2]) {
256 return errno_value_call(NACL_SYSCALL(utimes)(path, times)); 270 return errno_value_call(NACL_SYSCALL(utimes)(path, times));
257 } 271 }
258 272
259 /* 273 /*
260 * This is a stub since _start will call it but we don't want to 274 * This is a stub since _start will call it but we don't want to
261 * do the normal initialization. 275 * do the normal initialization.
262 */ 276 */
263 void __libnacl_irt_init(Elf32_auxv_t *auxv) { 277 void __libnacl_irt_init(Elf32_auxv_t *auxv) {
264 } 278 }
265 279
266 /* 280 /*
267 * These have to be weak because the IRT defines its own versions. 281 * These have to be weak because the IRT defines its own versions.
268 */ 282 */
269 __attribute__((weak)) int nacl_tls_init(void *thread_ptr) { 283 __attribute__((weak)) int nacl_tls_init(void *thread_ptr) {
270 return -NACL_SYSCALL(tls_init)(thread_ptr); 284 return -NACL_SYSCALL(tls_init)(thread_ptr);
271 } 285 }
272 286
273 __attribute__((weak)) void *nacl_tls_get(void) { 287 __attribute__((weak)) void *nacl_tls_get(void) {
274 return NACL_SYSCALL(tls_get)(); 288 return NACL_SYSCALL(tls_get)();
275 } 289 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698