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