Changeset 387 for asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.c
- Timestamp:
- May 22, 2019, 4:09:18 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.c
r374 r387 58 58 #include "util/ntopt.h" 59 59 #include "ntshell_main.h" 60 #include " socket_stub.h"60 #include "fdtable.h" 61 61 62 62 char command[NTOPT_TEXT_MAXLEN]; … … 78 78 } 79 79 80 void stdio_open(ID portid); 80 81 static int usrcmd_ntopt_callback(long *args, void *extobj); 81 82 … … 86 87 void ntshell_task_init(ID portid) 87 88 { 88 s erial_ctl_por(portid, IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV);89 stdio_open(portid); 89 90 } 90 91 … … 95 96 { 96 97 ntshell_state = 1; 97 ntshell_exit_code = ntopt_parse(command, usrcmd_ntopt_callback, NULL); 98 99 if (setjmp(process_exit) == 0) { 100 ntshell_exit_code = ntopt_parse(command, usrcmd_ntopt_callback, NULL); 101 } 102 103 fflush(stdout); 104 clean_fd(); 105 98 106 ntshell_state = 2; 99 107 } … … 139 147 printf("Unknown command found.\n"); 140 148 141 clean_fd();142 143 149 return result; 144 150 } … … 285 291 } 286 292 287 struct sigaction sigtable[7]; 288 289 int shell_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old) 290 { 291 struct sigaction *sat; 293 // musl-1.1.18\src\internal\ksigaction.h 294 struct k_sigaction { 295 void(*handler)(int); 296 unsigned long flags; 297 void(*restorer)(void); 298 unsigned mask[2]; 299 }; 300 301 struct k_sigaction sigtable[7]; 302 303 int shell_sigaction(int sig, const struct k_sigaction *__restrict sa, 304 struct k_sigaction *__restrict old, size_t size) 305 { 306 struct k_sigaction *sat; 292 307 293 308 switch(sig){ … … 318 333 319 334 if (old != NULL) 320 memcpy(old, sat, sizeof(struct sigaction));321 322 memcpy(sat, sa, sizeof(struct sigaction));335 memcpy(old, sat, offsetof(struct k_sigaction, mask) + size); 336 337 memcpy(sat, sa, offsetof(struct k_sigaction, mask) + size); 323 338 324 339 return 0; … … 368 383 } 369 384 385 int shell_nanosleep(const struct timespec *req, struct timespec *rem) 386 { 387 ER ret; 388 TMO tmo; 389 SYSTIM prev, now, diff; 390 391 if ((req == NULL) || (req->tv_nsec < 0) || (req->tv_nsec >= 1000000000)) 392 return -EINVAL; 393 394 get_tim(&prev); 395 396 tmo = req->tv_sec * 1000000 + req->tv_nsec / 1000; 397 ret = tslp_tsk(tmo); 398 if (ret == E_OK) { 399 if (rem != NULL) { 400 get_tim(&now); 401 diff = now - prev; 402 rem->tv_sec = diff / 1000000ll; 403 rem->tv_nsec = (diff - (rem->tv_sec * 1000000ll)) * 1000ll; 404 } 405 return 0; 406 } 407 else if (ret == E_TMOUT) { 408 if (rem != NULL) { 409 rem->tv_sec = 0; 410 rem->tv_nsec = 0; 411 } 412 return 0; 413 } 414 415 return -EFAULT; 416 }
Note:
See TracChangeset
for help on using the changeset viewer.