Revision 992f48a0 linux-user/syscall.c

b/linux-user/syscall.c
368 368
    return err;
369 369
}
370 370

  
371
static inline target_long get_errno(target_long ret)
371
static inline abi_long get_errno(abi_long ret)
372 372
{
373 373
    if (ret == -1)
374 374
        return -host_to_target_errno(errno);
......
376 376
        return ret;
377 377
}
378 378

  
379
static inline int is_error(target_long ret)
379
static inline int is_error(abi_long ret)
380 380
{
381
    return (target_ulong)ret >= (target_ulong)(-4096);
381
    return (abi_ulong)ret >= (abi_ulong)(-4096);
382 382
}
383 383

  
384
static target_ulong target_brk;
385
static target_ulong target_original_brk;
384
static abi_ulong target_brk;
385
static abi_ulong target_original_brk;
386 386

  
387
void target_set_brk(target_ulong new_brk)
387
void target_set_brk(abi_ulong new_brk)
388 388
{
389 389
    target_original_brk = target_brk = HOST_PAGE_ALIGN(new_brk);
390 390
}
391 391

  
392
target_long do_brk(target_ulong new_brk)
392
abi_long do_brk(abi_ulong new_brk)
393 393
{
394
    target_ulong brk_page;
395
    target_long mapped_addr;
394
    abi_ulong brk_page;
395
    abi_long mapped_addr;
396 396
    int	new_alloc_size;
397 397

  
398 398
    if (!new_brk)
......
422 422
}
423 423

  
424 424
static inline fd_set *target_to_host_fds(fd_set *fds,
425
                                         target_long *target_fds, int n)
425
                                         abi_long *target_fds, int n)
426 426
{
427 427
#if !defined(BSWAP_NEEDED) && !defined(WORDS_BIGENDIAN)
428 428
    return (fd_set *)target_fds;
......
431 431
    if (target_fds) {
432 432
        FD_ZERO(fds);
433 433
        for(i = 0;i < n; i++) {
434
            b = (tswapl(target_fds[i / TARGET_LONG_BITS]) >>
435
                 (i & (TARGET_LONG_BITS - 1))) & 1;
434
            b = (tswapl(target_fds[i / TARGET_ABI_BITS]) >>
435
                 (i & (TARGET_ABI_BITS - 1))) & 1;
436 436
            if (b)
437 437
                FD_SET(i, fds);
438 438
        }
......
443 443
#endif
444 444
}
445 445

  
446
static inline void host_to_target_fds(target_long *target_fds,
446
static inline void host_to_target_fds(abi_long *target_fds,
447 447
                                      fd_set *fds, int n)
448 448
{
449 449
#if !defined(BSWAP_NEEDED) && !defined(WORDS_BIGENDIAN)
450 450
    /* nothing to do */
451 451
#else
452 452
    int i, nw, j, k;
453
    target_long v;
453
    abi_long v;
454 454

  
455 455
    if (target_fds) {
456
        nw = (n + TARGET_LONG_BITS - 1) / TARGET_LONG_BITS;
456
        nw = (n + TARGET_ABI_BITS - 1) / TARGET_ABI_BITS;
457 457
        k = 0;
458 458
        for(i = 0;i < nw; i++) {
459 459
            v = 0;
460
            for(j = 0; j < TARGET_LONG_BITS; j++) {
460
            for(j = 0; j < TARGET_ABI_BITS; j++) {
461 461
                v |= ((FD_ISSET(k, fds) != 0) << j);
462 462
                k++;
463 463
            }
......
473 473
#define HOST_HZ 100
474 474
#endif
475 475

  
476
static inline target_long host_to_target_clock_t(long ticks)
476
static inline abi_long host_to_target_clock_t(long ticks)
477 477
{
478 478
#if HOST_HZ == TARGET_HZ
479 479
    return ticks;
......
482 482
#endif
483 483
}
484 484

  
485
static inline void host_to_target_rusage(target_ulong target_addr,
485
static inline void host_to_target_rusage(abi_ulong target_addr,
486 486
                                         const struct rusage *rusage)
487 487
{
488 488
    struct target_rusage *target_rusage;
......
510 510
}
511 511

  
512 512
static inline void target_to_host_timeval(struct timeval *tv,
513
                                          target_ulong target_addr)
513
                                          abi_ulong target_addr)
514 514
{
515 515
    struct target_timeval *target_tv;
516 516

  
......
520 520
    unlock_user_struct(target_tv, target_addr, 0);
521 521
}
522 522

  
523
static inline void host_to_target_timeval(target_ulong target_addr,
523
static inline void host_to_target_timeval(abi_ulong target_addr,
524 524
                                          const struct timeval *tv)
525 525
{
526 526
    struct target_timeval *target_tv;
......
532 532
}
533 533

  
534 534

  
535
static target_long do_select(int n,
536
                             target_ulong rfd_p, target_ulong wfd_p,
537
                             target_ulong efd_p, target_ulong target_tv)
535
static abi_long do_select(int n,
536
                          abi_ulong rfd_p, abi_ulong wfd_p,
537
                          abi_ulong efd_p, abi_ulong target_tv)
538 538
{
539 539
    fd_set rfds, wfds, efds;
540 540
    fd_set *rfds_ptr, *wfds_ptr, *efds_ptr;
541
    target_long *target_rfds, *target_wfds, *target_efds;
541
    abi_long *target_rfds, *target_wfds, *target_efds;
542 542
    struct timeval tv, *tv_ptr;
543
    target_long ret;
543
    abi_long ret;
544 544
    int ok;
545 545

  
546 546
    if (rfd_p) {
547
        target_rfds = lock_user(rfd_p, sizeof(target_long) * n, 1);
547
        target_rfds = lock_user(rfd_p, sizeof(abi_long) * n, 1);
548 548
        rfds_ptr = target_to_host_fds(&rfds, target_rfds, n);
549 549
    } else {
550 550
        target_rfds = NULL;
551 551
        rfds_ptr = NULL;
552 552
    }
553 553
    if (wfd_p) {
554
        target_wfds = lock_user(wfd_p, sizeof(target_long) * n, 1);
554
        target_wfds = lock_user(wfd_p, sizeof(abi_long) * n, 1);
555 555
        wfds_ptr = target_to_host_fds(&wfds, target_wfds, n);
556 556
    } else {
557 557
        target_wfds = NULL;
558 558
        wfds_ptr = NULL;
559 559
    }
560 560
    if (efd_p) {
561
        target_efds = lock_user(efd_p, sizeof(target_long) * n, 1);
561
        target_efds = lock_user(efd_p, sizeof(abi_long) * n, 1);
562 562
        efds_ptr = target_to_host_fds(&efds, target_efds, n);
563 563
    } else {
564 564
        target_efds = NULL;
......
584 584
        }
585 585
    }
586 586
    if (target_rfds)
587
        unlock_user(target_rfds, rfd_p, ok ? sizeof(target_long) * n : 0);
587
        unlock_user(target_rfds, rfd_p, ok ? sizeof(abi_long) * n : 0);
588 588
    if (target_wfds)
589
        unlock_user(target_wfds, wfd_p, ok ? sizeof(target_long) * n : 0);
589
        unlock_user(target_wfds, wfd_p, ok ? sizeof(abi_long) * n : 0);
590 590
    if (target_efds)
591
        unlock_user(target_efds, efd_p, ok ? sizeof(target_long) * n : 0);
591
        unlock_user(target_efds, efd_p, ok ? sizeof(abi_long) * n : 0);
592 592

  
593 593
    return ret;
594 594
}
595 595

  
596 596
static inline void target_to_host_sockaddr(struct sockaddr *addr,
597
                                           target_ulong target_addr,
597
                                           abi_ulong target_addr,
598 598
                                           socklen_t len)
599 599
{
600 600
    struct target_sockaddr *target_saddr;
......
605 605
    unlock_user(target_saddr, target_addr, 0);
606 606
}
607 607

  
608
static inline void host_to_target_sockaddr(target_ulong target_addr,
608
static inline void host_to_target_sockaddr(abi_ulong target_addr,
609 609
                                           struct sockaddr *addr,
610 610
                                           socklen_t len)
611 611
{
......
706 706
    msgh->msg_controllen = tswapl(space);
707 707
}
708 708

  
709
static target_long do_setsockopt(int sockfd, int level, int optname,
710
                                 target_ulong optval, socklen_t optlen)
709
static abi_long do_setsockopt(int sockfd, int level, int optname,
710
                              abi_ulong optval, socklen_t optlen)
711 711
{
712
    target_long ret;
712
    abi_long ret;
713 713
    int val;
714 714

  
715 715
    switch(level) {
......
827 827
    return ret;
828 828
}
829 829

  
830
static target_long do_getsockopt(int sockfd, int level, int optname,
831
                                 target_ulong optval, target_ulong optlen)
830
static abi_long do_getsockopt(int sockfd, int level, int optname,
831
                              abi_ulong optval, abi_ulong optlen)
832 832
{
833
    target_long ret;
833
    abi_long ret;
834 834
    int len, lv, val;
835 835

  
836 836
    switch(level) {
......
916 916
    return ret;
917 917
}
918 918

  
919
static void lock_iovec(struct iovec *vec, target_ulong target_addr,
919
static void lock_iovec(struct iovec *vec, abi_ulong target_addr,
920 920
                       int count, int copy)
921 921
{
922 922
    struct target_iovec *target_vec;
923
    target_ulong base;
923
    abi_ulong base;
924 924
    int i;
925 925

  
926 926
    target_vec = lock_user(target_addr, count * sizeof(struct target_iovec), 1);
......
932 932
    unlock_user (target_vec, target_addr, 0);
933 933
}
934 934

  
935
static void unlock_iovec(struct iovec *vec, target_ulong target_addr,
935
static void unlock_iovec(struct iovec *vec, abi_ulong target_addr,
936 936
                         int count, int copy)
937 937
{
938 938
    struct target_iovec *target_vec;
939
    target_ulong base;
939
    abi_ulong base;
940 940
    int i;
941 941

  
942 942
    target_vec = lock_user(target_addr, count * sizeof(struct target_iovec), 1);
......
947 947
    unlock_user (target_vec, target_addr, 0);
948 948
}
949 949

  
950
static target_long do_socket(int domain, int type, int protocol)
950
static abi_long do_socket(int domain, int type, int protocol)
951 951
{
952 952
#if defined(TARGET_MIPS)
953 953
    switch(type) {
......
974 974
    return get_errno(socket(domain, type, protocol));
975 975
}
976 976

  
977
static target_long do_bind(int sockfd, target_ulong target_addr,
978
                           socklen_t addrlen)
977
static abi_long do_bind(int sockfd, abi_ulong target_addr,
978
                        socklen_t addrlen)
979 979
{
980 980
    void *addr = alloca(addrlen);
981 981

  
......
983 983
    return get_errno(bind(sockfd, addr, addrlen));
984 984
}
985 985

  
986
static target_long do_connect(int sockfd, target_ulong target_addr,
987
                              socklen_t addrlen)
986
static abi_long do_connect(int sockfd, abi_ulong target_addr,
987
                           socklen_t addrlen)
988 988
{
989 989
    void *addr = alloca(addrlen);
990 990

  
......
992 992
    return get_errno(connect(sockfd, addr, addrlen));
993 993
}
994 994

  
995
static target_long do_sendrecvmsg(int fd, target_ulong target_msg,
996
                                  int flags, int send)
995
static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg,
996
                               int flags, int send)
997 997
{
998
    target_long ret;
998
    abi_long ret;
999 999
    struct target_msghdr *msgp;
1000 1000
    struct msghdr msg;
1001 1001
    int count;
1002 1002
    struct iovec *vec;
1003
    target_ulong target_vec;
1003
    abi_ulong target_vec;
1004 1004

  
1005 1005
    lock_user_struct(msgp, target_msg, 1);
1006 1006
    if (msgp->msg_name) {
......
1035 1035
    return ret;
1036 1036
}
1037 1037

  
1038
static target_long do_accept(int fd, target_ulong target_addr,
1039
                             target_ulong target_addrlen)
1038
static abi_long do_accept(int fd, abi_ulong target_addr,
1039
                          abi_ulong target_addrlen)
1040 1040
{
1041 1041
    socklen_t addrlen = tget32(target_addrlen);
1042 1042
    void *addr = alloca(addrlen);
1043
    target_long ret;
1043
    abi_long ret;
1044 1044

  
1045 1045
    ret = get_errno(accept(fd, addr, &addrlen));
1046 1046
    if (!is_error(ret)) {
......
1050 1050
    return ret;
1051 1051
}
1052 1052

  
1053
static target_long do_getpeername(int fd, target_ulong target_addr,
1054
                                  target_ulong target_addrlen)
1053
static abi_long do_getpeername(int fd, abi_ulong target_addr,
1054
                               abi_ulong target_addrlen)
1055 1055
{
1056 1056
    socklen_t addrlen = tget32(target_addrlen);
1057 1057
    void *addr = alloca(addrlen);
1058
    target_long ret;
1058
    abi_long ret;
1059 1059

  
1060 1060
    ret = get_errno(getpeername(fd, addr, &addrlen));
1061 1061
    if (!is_error(ret)) {
......
1065 1065
    return ret;
1066 1066
}
1067 1067

  
1068
static target_long do_getsockname(int fd, target_ulong target_addr,
1069
                                  target_ulong target_addrlen)
1068
static abi_long do_getsockname(int fd, abi_ulong target_addr,
1069
                               abi_ulong target_addrlen)
1070 1070
{
1071 1071
    socklen_t addrlen = tget32(target_addrlen);
1072 1072
    void *addr = alloca(addrlen);
1073
    target_long ret;
1073
    abi_long ret;
1074 1074

  
1075 1075
    ret = get_errno(getsockname(fd, addr, &addrlen));
1076 1076
    if (!is_error(ret)) {
......
1080 1080
    return ret;
1081 1081
}
1082 1082

  
1083
static target_long do_socketpair(int domain, int type, int protocol,
1084
                                 target_ulong target_tab)
1083
static abi_long do_socketpair(int domain, int type, int protocol,
1084
                              abi_ulong target_tab)
1085 1085
{
1086 1086
    int tab[2];
1087
    target_long ret;
1087
    abi_long ret;
1088 1088

  
1089 1089
    ret = get_errno(socketpair(domain, type, protocol, tab));
1090 1090
    if (!is_error(ret)) {
......
1094 1094
    return ret;
1095 1095
}
1096 1096

  
1097
static target_long do_sendto(int fd, target_ulong msg, size_t len, int flags,
1098
                             target_ulong target_addr, socklen_t addrlen)
1097
static abi_long do_sendto(int fd, abi_ulong msg, size_t len, int flags,
1098
                          abi_ulong target_addr, socklen_t addrlen)
1099 1099
{
1100 1100
    void *addr;
1101 1101
    void *host_msg;
1102
    target_long ret;
1102
    abi_long ret;
1103 1103

  
1104 1104
    host_msg = lock_user(msg, len, 1);
1105 1105
    if (target_addr) {
......
1113 1113
    return ret;
1114 1114
}
1115 1115

  
1116
static target_long do_recvfrom(int fd, target_ulong msg, size_t len, int flags,
1117
                               target_ulong target_addr,
1118
                               target_ulong target_addrlen)
1116
static abi_long do_recvfrom(int fd, abi_ulong msg, size_t len, int flags,
1117
                            abi_ulong target_addr,
1118
                            abi_ulong target_addrlen)
1119 1119
{
1120 1120
    socklen_t addrlen;
1121 1121
    void *addr;
1122 1122
    void *host_msg;
1123
    target_long ret;
1123
    abi_long ret;
1124 1124

  
1125 1125
    host_msg = lock_user(msg, len, 0);
1126 1126
    if (target_addr) {
......
1144 1144
}
1145 1145

  
1146 1146
#ifdef TARGET_NR_socketcall
1147
static target_long do_socketcall(int num, target_ulong vptr)
1147
static abi_long do_socketcall(int num, abi_ulong vptr)
1148 1148
{
1149
    target_long ret;
1150
    const int n = sizeof(target_ulong);
1149
    abi_long ret;
1150
    const int n = sizeof(abi_ulong);
1151 1151

  
1152 1152
    switch(num) {
1153 1153
    case SOCKOP_socket:
......
1161 1161
    case SOCKOP_bind:
1162 1162
	{
1163 1163
            int sockfd = tgetl(vptr);
1164
            target_ulong target_addr = tgetl(vptr + n);
1164
            abi_ulong target_addr = tgetl(vptr + n);
1165 1165
            socklen_t addrlen = tgetl(vptr + 2 * n);
1166 1166
            ret = do_bind(sockfd, target_addr, addrlen);
1167 1167
        }
......
1169 1169
    case SOCKOP_connect:
1170 1170
        {
1171 1171
            int sockfd = tgetl(vptr);
1172
            target_ulong target_addr = tgetl(vptr + n);
1172
            abi_ulong target_addr = tgetl(vptr + n);
1173 1173
            socklen_t addrlen = tgetl(vptr + 2 * n);
1174 1174
            ret = do_connect(sockfd, target_addr, addrlen);
1175 1175
        }
......
1184 1184
    case SOCKOP_accept:
1185 1185
        {
1186 1186
            int sockfd = tgetl(vptr);
1187
            target_ulong target_addr = tgetl(vptr + n);
1188
            target_ulong target_addrlen = tgetl(vptr + 2 * n);
1187
            abi_ulong target_addr = tgetl(vptr + n);
1188
            abi_ulong target_addrlen = tgetl(vptr + 2 * n);
1189 1189
            ret = do_accept(sockfd, target_addr, target_addrlen);
1190 1190
        }
1191 1191
        break;
1192 1192
    case SOCKOP_getsockname:
1193 1193
        {
1194 1194
            int sockfd = tgetl(vptr);
1195
            target_ulong target_addr = tgetl(vptr + n);
1196
            target_ulong target_addrlen = tgetl(vptr + 2 * n);
1195
            abi_ulong target_addr = tgetl(vptr + n);
1196
            abi_ulong target_addrlen = tgetl(vptr + 2 * n);
1197 1197
            ret = do_getsockname(sockfd, target_addr, target_addrlen);
1198 1198
        }
1199 1199
        break;
1200 1200
    case SOCKOP_getpeername:
1201 1201
        {
1202 1202
            int sockfd = tgetl(vptr);
1203
            target_ulong target_addr = tgetl(vptr + n);
1204
            target_ulong target_addrlen = tgetl(vptr + 2 * n);
1203
            abi_ulong target_addr = tgetl(vptr + n);
1204
            abi_ulong target_addrlen = tgetl(vptr + 2 * n);
1205 1205
            ret = do_getpeername(sockfd, target_addr, target_addrlen);
1206 1206
        }
1207 1207
        break;
......
1210 1210
            int domain = tgetl(vptr);
1211 1211
            int type = tgetl(vptr + n);
1212 1212
            int protocol = tgetl(vptr + 2 * n);
1213
            target_ulong tab = tgetl(vptr + 3 * n);
1213
            abi_ulong tab = tgetl(vptr + 3 * n);
1214 1214
            ret = do_socketpair(domain, type, protocol, tab);
1215 1215
        }
1216 1216
        break;
1217 1217
    case SOCKOP_send:
1218 1218
        {
1219 1219
            int sockfd = tgetl(vptr);
1220
            target_ulong msg = tgetl(vptr + n);
1220
            abi_ulong msg = tgetl(vptr + n);
1221 1221
            size_t len = tgetl(vptr + 2 * n);
1222 1222
            int flags = tgetl(vptr + 3 * n);
1223 1223
            ret = do_sendto(sockfd, msg, len, flags, 0, 0);
......
1226 1226
    case SOCKOP_recv:
1227 1227
        {
1228 1228
            int sockfd = tgetl(vptr);
1229
            target_ulong msg = tgetl(vptr + n);
1229
            abi_ulong msg = tgetl(vptr + n);
1230 1230
            size_t len = tgetl(vptr + 2 * n);
1231 1231
            int flags = tgetl(vptr + 3 * n);
1232 1232
            ret = do_recvfrom(sockfd, msg, len, flags, 0, 0);
......
1235 1235
    case SOCKOP_sendto:
1236 1236
        {
1237 1237
            int sockfd = tgetl(vptr);
1238
            target_ulong msg = tgetl(vptr + n);
1238
            abi_ulong msg = tgetl(vptr + n);
1239 1239
            size_t len = tgetl(vptr + 2 * n);
1240 1240
            int flags = tgetl(vptr + 3 * n);
1241
            target_ulong addr = tgetl(vptr + 4 * n);
1241
            abi_ulong addr = tgetl(vptr + 4 * n);
1242 1242
            socklen_t addrlen = tgetl(vptr + 5 * n);
1243 1243
            ret = do_sendto(sockfd, msg, len, flags, addr, addrlen);
1244 1244
        }
......
1246 1246
    case SOCKOP_recvfrom:
1247 1247
        {
1248 1248
            int sockfd = tgetl(vptr);
1249
            target_ulong msg = tgetl(vptr + n);
1249
            abi_ulong msg = tgetl(vptr + n);
1250 1250
            size_t len = tgetl(vptr + 2 * n);
1251 1251
            int flags = tgetl(vptr + 3 * n);
1252
            target_ulong addr = tgetl(vptr + 4 * n);
1253
            target_ulong addrlen = tgetl(vptr + 5 * n);
1252
            abi_ulong addr = tgetl(vptr + 4 * n);
1253
            abi_ulong addrlen = tgetl(vptr + 5 * n);
1254 1254
            ret = do_recvfrom(sockfd, msg, len, flags, addr, addrlen);
1255 1255
        }
1256 1256
        break;
......
1266 1266
    case SOCKOP_recvmsg:
1267 1267
        {
1268 1268
            int fd;
1269
            target_ulong target_msg;
1269
            abi_ulong target_msg;
1270 1270
            int flags;
1271 1271

  
1272 1272
            fd = tgetl(vptr);
......
1282 1282
            int sockfd = tgetl(vptr);
1283 1283
            int level = tgetl(vptr + n);
1284 1284
            int optname = tgetl(vptr + 2 * n);
1285
            target_ulong optval = tgetl(vptr + 3 * n);
1285
            abi_ulong optval = tgetl(vptr + 3 * n);
1286 1286
            socklen_t optlen = tgetl(vptr + 4 * n);
1287 1287

  
1288 1288
            ret = do_setsockopt(sockfd, level, optname, optval, optlen);
......
1293 1293
            int sockfd = tgetl(vptr);
1294 1294
            int level = tgetl(vptr + n);
1295 1295
            int optname = tgetl(vptr + 2 * n);
1296
            target_ulong optval = tgetl(vptr + 3 * n);
1297
            target_ulong poptlen = tgetl(vptr + 4 * n);
1296
            abi_ulong optval = tgetl(vptr + 3 * n);
1297
            abi_ulong poptlen = tgetl(vptr + 4 * n);
1298 1298

  
1299 1299
            ret = do_getsockopt(sockfd, level, optname, optval, poptlen);
1300 1300
        }
......
1318 1318

  
1319 1319
struct target_ipc_perm
1320 1320
{
1321
    target_long __key;
1322
    target_ulong uid;
1323
    target_ulong gid;
1324
    target_ulong cuid;
1325
    target_ulong cgid;
1321
    abi_long __key;
1322
    abi_ulong uid;
1323
    abi_ulong gid;
1324
    abi_ulong cuid;
1325
    abi_ulong cgid;
1326 1326
    unsigned short int mode;
1327 1327
    unsigned short int __pad1;
1328 1328
    unsigned short int __seq;
1329 1329
    unsigned short int __pad2;
1330
    target_ulong __unused1;
1331
    target_ulong __unused2;
1330
    abi_ulong __unused1;
1331
    abi_ulong __unused2;
1332 1332
};
1333 1333

  
1334 1334
struct target_semid_ds
1335 1335
{
1336 1336
  struct target_ipc_perm sem_perm;
1337
  target_ulong sem_otime;
1338
  target_ulong __unused1;
1339
  target_ulong sem_ctime;
1340
  target_ulong __unused2;
1341
  target_ulong sem_nsems;
1342
  target_ulong __unused3;
1343
  target_ulong __unused4;
1337
  abi_ulong sem_otime;
1338
  abi_ulong __unused1;
1339
  abi_ulong sem_ctime;
1340
  abi_ulong __unused2;
1341
  abi_ulong sem_nsems;
1342
  abi_ulong __unused3;
1343
  abi_ulong __unused4;
1344 1344
};
1345 1345

  
1346 1346
static inline void target_to_host_ipc_perm(struct ipc_perm *host_ip,
1347
                                           target_ulong target_addr)
1347
                                           abi_ulong target_addr)
1348 1348
{
1349 1349
    struct target_ipc_perm *target_ip;
1350 1350
    struct target_semid_ds *target_sd;
......
1360 1360
    unlock_user_struct(target_sd, target_addr, 0);
1361 1361
}
1362 1362

  
1363
static inline void host_to_target_ipc_perm(target_ulong target_addr,
1363
static inline void host_to_target_ipc_perm(abi_ulong target_addr,
1364 1364
                                           struct ipc_perm *host_ip)
1365 1365
{
1366 1366
    struct target_ipc_perm *target_ip;
......
1378 1378
}
1379 1379

  
1380 1380
static inline void target_to_host_semid_ds(struct semid_ds *host_sd,
1381
                                          target_ulong target_addr)
1381
                                          abi_ulong target_addr)
1382 1382
{
1383 1383
    struct target_semid_ds *target_sd;
1384 1384

  
......
1390 1390
    unlock_user_struct(target_sd, target_addr, 0);
1391 1391
}
1392 1392

  
1393
static inline void host_to_target_semid_ds(target_ulong target_addr,
1393
static inline void host_to_target_semid_ds(abi_ulong target_addr,
1394 1394
                                           struct semid_ds *host_sd)
1395 1395
{
1396 1396
    struct target_semid_ds *target_sd;
......
1411 1411

  
1412 1412
union target_semun {
1413 1413
	int val;
1414
	target_long buf;
1414
	abi_long buf;
1415 1415
	unsigned short int *array;
1416 1416
};
1417 1417

  
1418 1418
static inline void target_to_host_semun(int cmd,
1419 1419
                                        union semun *host_su,
1420
                                        target_ulong target_addr,
1420
                                        abi_ulong target_addr,
1421 1421
                                        struct semid_ds *ds)
1422 1422
{
1423 1423
    union target_semun *target_su;
......
1448 1448
}
1449 1449

  
1450 1450
static inline void host_to_target_semun(int cmd,
1451
                                        target_ulong target_addr,
1451
                                        abi_ulong target_addr,
1452 1452
                                        union semun *host_su,
1453 1453
                                        struct semid_ds *ds)
1454 1454
{
......
1478 1478
    }
1479 1479
}
1480 1480

  
1481
static inline target_long do_semctl(int first, int second, int third,
1482
                                    target_long ptr)
1481
static inline abi_long do_semctl(int first, int second, int third,
1482
                                 abi_long ptr)
1483 1483
{
1484 1484
    union semun arg;
1485 1485
    struct semid_ds dsarg;
1486 1486
    int cmd = third&0xff;
1487
    target_long ret = 0;
1487
    abi_long ret = 0;
1488 1488

  
1489 1489
    switch( cmd ) {
1490 1490
	case GETVAL:
......
1527 1527
struct target_msqid_ds
1528 1528
{
1529 1529
  struct target_ipc_perm msg_perm;
1530
  target_ulong msg_stime;
1531
  target_ulong __unused1;
1532
  target_ulong msg_rtime;
1533
  target_ulong __unused2;
1534
  target_ulong msg_ctime;
1535
  target_ulong __unused3;
1536
  target_ulong __msg_cbytes;
1537
  target_ulong msg_qnum;
1538
  target_ulong msg_qbytes;
1539
  target_ulong msg_lspid;
1540
  target_ulong msg_lrpid;
1541
  target_ulong __unused4;
1542
  target_ulong __unused5;
1530
  abi_ulong msg_stime;
1531
  abi_ulong __unused1;
1532
  abi_ulong msg_rtime;
1533
  abi_ulong __unused2;
1534
  abi_ulong msg_ctime;
1535
  abi_ulong __unused3;
1536
  abi_ulong __msg_cbytes;
1537
  abi_ulong msg_qnum;
1538
  abi_ulong msg_qbytes;
1539
  abi_ulong msg_lspid;
1540
  abi_ulong msg_lrpid;
1541
  abi_ulong __unused4;
1542
  abi_ulong __unused5;
1543 1543
};
1544 1544

  
1545 1545
static inline void target_to_host_msqid_ds(struct msqid_ds *host_md,
1546
                                           target_ulong target_addr)
1546
                                           abi_ulong target_addr)
1547 1547
{
1548 1548
    struct target_msqid_ds *target_md;
1549 1549

  
......
1560 1560
    unlock_user_struct(target_md, target_addr, 0);
1561 1561
}
1562 1562

  
1563
static inline void host_to_target_msqid_ds(target_ulong target_addr,
1563
static inline void host_to_target_msqid_ds(abi_ulong target_addr,
1564 1564
                                           struct msqid_ds *host_md)
1565 1565
{
1566 1566
    struct target_msqid_ds *target_md;
......
1578 1578
    unlock_user_struct(target_md, target_addr, 1);
1579 1579
}
1580 1580

  
1581
static inline target_long do_msgctl(int first, int second, target_long ptr)
1581
static inline abi_long do_msgctl(int first, int second, abi_long ptr)
1582 1582
{
1583 1583
    struct msqid_ds dsarg;
1584 1584
    int cmd = second&0xff;
1585
    target_long ret = 0;
1585
    abi_long ret = 0;
1586 1586
    switch( cmd ) {
1587 1587
    case IPC_STAT:
1588 1588
    case IPC_SET:
......
1596 1596
}
1597 1597

  
1598 1598
struct target_msgbuf {
1599
	target_ulong mtype;
1599
	abi_ulong mtype;
1600 1600
	char	mtext[1];
1601 1601
};
1602 1602

  
1603
static inline target_long do_msgsnd(int msqid, target_long msgp,
1604
                                    unsigned int msgsz, int msgflg)
1603
static inline abi_long do_msgsnd(int msqid, abi_long msgp,
1604
                                 unsigned int msgsz, int msgflg)
1605 1605
{
1606 1606
    struct target_msgbuf *target_mb;
1607 1607
    struct msgbuf *host_mb;
1608
    target_long ret = 0;
1608
    abi_long ret = 0;
1609 1609

  
1610 1610
    lock_user_struct(target_mb,msgp,0);
1611 1611
    host_mb = malloc(msgsz+sizeof(long));
......
1618 1618
    return ret;
1619 1619
}
1620 1620

  
1621
static inline target_long do_msgrcv(int msqid, target_long msgp,
1622
                                    unsigned int msgsz, int msgtype,
1623
                                    int msgflg)
1621
static inline abi_long do_msgrcv(int msqid, abi_long msgp,
1622
                                 unsigned int msgsz, int msgtype,
1623
                                 int msgflg)
1624 1624
{
1625 1625
    struct target_msgbuf *target_mb;
1626 1626
    struct msgbuf *host_mb;
1627
    target_long ret = 0;
1627
    abi_long ret = 0;
1628 1628

  
1629 1629
    lock_user_struct(target_mb, msgp, 0);
1630 1630
    host_mb = malloc(msgsz+sizeof(long));
......
1639 1639
}
1640 1640

  
1641 1641
/* ??? This only works with linear mappings.  */
1642
static target_long do_ipc(unsigned int call, int first,
1643
                          int second, int third,
1644
                          target_long ptr, target_long fifth)
1642
static abi_long do_ipc(unsigned int call, int first,
1643
                       int second, int third,
1644
                       abi_long ptr, abi_long fifth)
1645 1645
{
1646 1646
    int version;
1647
    target_long ret = 0;
1647
    abi_long ret = 0;
1648 1648
    unsigned long raddr;
1649 1649
    struct shmid_ds shm_info;
1650 1650
    int i;
......
1722 1722
                break;
1723 1723
	    }
1724 1724
	}
1725
	if (put_user(raddr, (target_ulong *)third))
1725
	if (put_user(raddr, (abi_ulong *)third))
1726 1726
            return -EFAULT;
1727 1727
        ret = 0;
1728 1728
	break;
......
1803 1803
};
1804 1804

  
1805 1805
/* ??? Implement proper locking for ioctls.  */
1806
static target_long do_ioctl(int fd, target_long cmd, target_long arg)
1806
static abi_long do_ioctl(int fd, abi_long cmd, abi_long arg)
1807 1807
{
1808 1808
    const IOCTLEntry *ie;
1809 1809
    const argtype *arg_type;
1810
    target_long ret;
1810
    abi_long ret;
1811 1811
    uint8_t buf_temp[MAX_STRUCT_SIZE];
1812 1812
    int target_size;
1813 1813
    void *argptr;
......
2088 2088
/* NOTE: there is really one LDT for all the threads */
2089 2089
uint8_t *ldt_table;
2090 2090

  
2091
static int read_ldt(target_ulong ptr, unsigned long bytecount)
2091
static int read_ldt(abi_ulong ptr, unsigned long bytecount)
2092 2092
{
2093 2093
    int size;
2094 2094
    void *p;
......
2107 2107

  
2108 2108
/* XXX: add locking support */
2109 2109
static int write_ldt(CPUX86State *env,
2110
                     target_ulong ptr, unsigned long bytecount, int oldmode)
2110
                     abi_ulong ptr, unsigned long bytecount, int oldmode)
2111 2111
{
2112 2112
    struct target_modify_ldt_ldt_s ldt_info;
2113 2113
    struct target_modify_ldt_ldt_s *target_ldt_info;
......
2188 2188
}
2189 2189

  
2190 2190
/* specific and weird i386 syscalls */
2191
int do_modify_ldt(CPUX86State *env, int func, target_ulong ptr, unsigned long bytecount)
2191
int do_modify_ldt(CPUX86State *env, int func, abi_ulong ptr, unsigned long bytecount)
2192 2192
{
2193 2193
    int ret = -ENOSYS;
2194 2194

  
......
2220 2220
    return 0;
2221 2221
}
2222 2222

  
2223
int do_fork(CPUState *env, unsigned int flags, target_ulong newsp)
2223
int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp)
2224 2224
{
2225 2225
    int ret;
2226 2226
    TaskState *ts;
......
2310 2310
    return ret;
2311 2311
}
2312 2312

  
2313
static target_long do_fcntl(int fd, int cmd, target_ulong arg)
2313
static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)
2314 2314
{
2315 2315
    struct flock fl;
2316 2316
    struct target_flock *target_fl;
2317 2317
    struct flock64 fl64;
2318 2318
    struct target_flock64 *target_fl64;
2319
    target_long ret;
2319
    abi_long ret;
2320 2320

  
2321 2321
    switch(cmd) {
2322 2322
    case TARGET_F_GETLK:
......
2475 2475
    }
2476 2476
}
2477 2477

  
2478
#if TARGET_LONG_BITS == 32
2478
#if TARGET_ABI_BITS == 32
2479 2479
static inline uint64_t target_offset64(uint32_t word0, uint32_t word1)
2480 2480
{
2481 2481
#ifdef TARGET_WORDS_BIG_ENDIAN
......
2484 2484
    return ((uint64_t)word1 << 32) | word0;
2485 2485
#endif
2486 2486
}
2487
#else /* TARGET_LONG_BITS == 32 */
2487
#else /* TARGET_ABI_BITS == 32 */
2488 2488
static inline uint64_t target_offset64(uint64_t word0, uint64_t word1)
2489 2489
{
2490 2490
    return word0;
2491 2491
}
2492
#endif /* TARGET_LONG_BITS != 32 */
2492
#endif /* TARGET_ABI_BITS != 32 */
2493 2493

  
2494 2494
#ifdef TARGET_NR_truncate64
2495
static inline target_long target_truncate64(void *cpu_env, const char *arg1,
2496
                                            target_long arg2,
2497
                                            target_long arg3,
2498
                                            target_long arg4)
2495
static inline abi_long target_truncate64(void *cpu_env, const char *arg1,
2496
                                         abi_long arg2,
2497
                                         abi_long arg3,
2498
                                         abi_long arg4)
2499 2499
{
2500 2500
#ifdef TARGET_ARM
2501 2501
    if (((CPUARMState *)cpu_env)->eabi)
......
2509 2509
#endif
2510 2510

  
2511 2511
#ifdef TARGET_NR_ftruncate64
2512
static inline target_long target_ftruncate64(void *cpu_env, target_long arg1,
2513
                                             target_long arg2,
2514
                                             target_long arg3,
2515
                                             target_long arg4)
2512
static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1,
2513
                                          abi_long arg2,
2514
                                          abi_long arg3,
2515
                                          abi_long arg4)
2516 2516
{
2517 2517
#ifdef TARGET_ARM
2518 2518
    if (((CPUARMState *)cpu_env)->eabi)
......
2526 2526
#endif
2527 2527

  
2528 2528
static inline void target_to_host_timespec(struct timespec *host_ts,
2529
                                           target_ulong target_addr)
2529
                                           abi_ulong target_addr)
2530 2530
{
2531 2531
    struct target_timespec *target_ts;
2532 2532

  
......
2536 2536
    unlock_user_struct(target_ts, target_addr, 0);
2537 2537
}
2538 2538

  
2539
static inline void host_to_target_timespec(target_ulong target_addr,
2539
static inline void host_to_target_timespec(abi_ulong target_addr,
2540 2540
                                           struct timespec *host_ts)
2541 2541
{
2542 2542
    struct target_timespec *target_ts;
......
2547 2547
    unlock_user_struct(target_ts, target_addr, 1);
2548 2548
}
2549 2549

  
2550
target_long do_syscall(void *cpu_env, int num, target_long arg1,
2551
                       target_long arg2, target_long arg3, target_long arg4,
2552
                       target_long arg5, target_long arg6)
2550
abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
2551
                    abi_long arg2, abi_long arg3, abi_long arg4,
2552
                    abi_long arg5, abi_long arg6)
2553 2553
{
2554
    target_long ret;
2554
    abi_long ret;
2555 2555
    struct stat st;
2556 2556
    struct statfs stfs;
2557 2557
    void *p;
......
2687 2687
        {
2688 2688
            char **argp, **envp;
2689 2689
            int argc, envc;
2690
            target_ulong gp;
2691
            target_ulong guest_argp;
2692
            target_ulong guest_envp;
2693
            target_ulong addr;
2690
            abi_ulong gp;
2691
            abi_ulong guest_argp;
2692
            abi_ulong guest_envp;
2693
            abi_ulong addr;
2694 2694
            char **q;
2695 2695

  
2696 2696
            argc = 0;
......
2706 2706
            envp = alloca((envc + 1) * sizeof(void *));
2707 2707

  
2708 2708
            for (gp = guest_argp, q = argp; ;
2709
                  gp += sizeof(target_ulong), q++) {
2709
                  gp += sizeof(abi_ulong), q++) {
2710 2710
                addr = tgetl(gp);
2711 2711
                if (!addr)
2712 2712
                    break;
......
2715 2715
            *q = NULL;
2716 2716

  
2717 2717
            for (gp = guest_envp, q = envp; ;
2718
                  gp += sizeof(target_ulong), q++) {
2718
                  gp += sizeof(abi_ulong), q++) {
2719 2719
                addr = tgetl(gp);
2720 2720
                if (!addr)
2721 2721
                    break;
......
2728 2728
            unlock_user(p, arg1, 0);
2729 2729

  
2730 2730
            for (gp = guest_argp, q = argp; *q;
2731
                  gp += sizeof(target_ulong), q++) {
2731
                  gp += sizeof(abi_ulong), q++) {
2732 2732
                addr = tgetl(gp);
2733 2733
                unlock_user(*q, addr, 0);
2734 2734
            }
2735 2735
            for (gp = guest_envp, q = envp; *q;
2736
                  gp += sizeof(target_ulong), q++) {
2736
                  gp += sizeof(abi_ulong), q++) {
2737 2737
                addr = tgetl(gp);
2738 2738
                unlock_user(*q, addr, 0);
2739 2739
            }
......
3163 3163
    case TARGET_NR_sgetmask:
3164 3164
        {
3165 3165
            sigset_t cur_set;
3166
            target_ulong target_set;
3166
            abi_ulong target_set;
3167 3167
            sigprocmask(0, NULL, &cur_set);
3168 3168
            host_to_target_old_sigset(&target_set, &cur_set);
3169 3169
            ret = target_set;
......
3174 3174
    case TARGET_NR_ssetmask:
3175 3175
        {
3176 3176
            sigset_t set, oset, cur_set;
3177
            target_ulong target_set = arg1;
3177
            abi_ulong target_set = arg1;
3178 3178
            sigprocmask(0, NULL, &cur_set);
3179 3179
            target_to_host_old_sigset(&set, &target_set);
3180 3180
            sigorset(&set, &set, &cur_set);
......
3407 3407
    case TARGET_NR_select:
3408 3408
        {
3409 3409
            struct target_sel_arg_struct *sel;
3410
            target_ulong inp, outp, exp, tvp;
3410
            abi_ulong inp, outp, exp, tvp;
3411 3411
            long nsel;
3412 3412

  
3413 3413
            lock_user_struct(sel, arg1, 1);
......
3510 3510
    case TARGET_NR_mmap:
3511 3511
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_CRIS)
3512 3512
        {
3513
            target_ulong *v;
3514
            target_ulong v1, v2, v3, v4, v5, v6;
3515
            v = lock_user(arg1, 6 * sizeof(target_ulong), 1);
3513
            abi_ulong *v;
3514
            abi_ulong v1, v2, v3, v4, v5, v6;
3515
            v = lock_user(arg1, 6 * sizeof(abi_ulong), 1);
3516 3516
            v1 = tswapl(v[0]);
3517 3517
            v2 = tswapl(v[1]);
3518 3518
            v3 = tswapl(v[2]);
......
3829 3829
                struct target_stat *target_st;
3830 3830

  
3831 3831
                lock_user_struct(target_st, arg2, 0);
3832
#if defined(TARGET_MIPS) || defined(TARGET_SPARC64)
3832
#if defined(TARGET_MIPS) || (defined(TARGET_SPARC64) && !defined(TARGET_ABI32))
3833 3833
                target_st->st_dev = tswap32(st.st_dev);
3834 3834
#else
3835 3835
                target_st->st_dev = tswap16(st.st_dev);
......
3839 3839
                target_st->st_mode = tswapl(st.st_mode); /* XXX: check this */
3840 3840
                target_st->st_uid = tswap32(st.st_uid);
3841 3841
                target_st->st_gid = tswap32(st.st_gid);
3842
#elif defined(TARGET_SPARC64)
3842
#elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
3843 3843
                target_st->st_mode = tswap32(st.st_mode);
3844 3844
                target_st->st_uid = tswap32(st.st_uid);
3845 3845
                target_st->st_gid = tswap32(st.st_gid);
......
3852 3852
		/* If this is the same on PPC, then just merge w/ the above ifdef */
3853 3853
                target_st->st_nlink = tswapl(st.st_nlink);
3854 3854
                target_st->st_rdev = tswapl(st.st_rdev);
3855
#elif defined(TARGET_SPARC64)
3855
#elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
3856 3856
                target_st->st_nlink = tswap32(st.st_nlink);
3857 3857
                target_st->st_rdev = tswap32(st.st_rdev);
3858 3858
#else
......
3892 3892
    case TARGET_NR_wait4:
3893 3893
        {
3894 3894
            int status;
3895
            target_long status_ptr = arg2;
3895
            abi_long status_ptr = arg2;
3896 3896
            struct rusage rusage, *rusage_ptr;
3897
            target_ulong target_rusage = arg4;
3897
            abi_ulong target_rusage = arg4;
3898 3898
            if (target_rusage)
3899 3899
                rusage_ptr = &rusage;
3900 3900
            else
......
4045 4045
        break;
4046 4046
#endif
4047 4047
    case TARGET_NR_getdents:
4048
#if TARGET_LONG_SIZE != 4
4048
#if TARGET_ABI_BITS != 32
4049 4049
        goto unimplemented;
4050 4050
#warning not supported
4051
#elif TARGET_LONG_SIZE == 4 && HOST_LONG_SIZE == 8
4051
#elif TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64
4052 4052
        {
4053 4053
            struct target_dirent *target_dirp;
4054 4054
            struct dirent *dirp;
4055
            target_long count = arg3;
4055
            abi_long count = arg3;
4056 4056

  
4057 4057
	    dirp = malloc(count);
4058 4058
	    if (!dirp)
......
4072 4072
		tde = target_dirp;
4073 4073
                while (len > 0) {
4074 4074
                    reclen = de->d_reclen;
4075
		    treclen = reclen - (2 * (sizeof(long) - sizeof(target_long)));
4075
		    treclen = reclen - (2 * (sizeof(long) - sizeof(abi_long)));
4076 4076
                    tde->d_reclen = tswap16(treclen);
4077 4077
                    tde->d_ino = tswapl(de->d_ino);
4078 4078
                    tde->d_off = tswapl(de->d_off);
4079
		    tnamelen = treclen - (2 * sizeof(target_long) + 2);
4079
		    tnamelen = treclen - (2 * sizeof(abi_long) + 2);
4080 4080
		    if (tnamelen > 256)
4081 4081
                        tnamelen = 256;
4082 4082
                    /* XXX: may not be correct */
......
4094 4094
#else
4095 4095
        {
4096 4096
            struct dirent *dirp;
4097
            target_long count = arg3;
4097
            abi_long count = arg3;
4098 4098

  
4099 4099
            dirp = lock_user(arg2, count, 0);
4100 4100
            ret = get_errno(sys_getdents(arg1, dirp, count));
......
4122 4122
    case TARGET_NR_getdents64:
4123 4123
        {
4124 4124
            struct dirent64 *dirp;
4125
            target_long count = arg3;
4125
            abi_long count = arg3;
4126 4126
            dirp = lock_user(arg2, count, 0);
4127 4127
            ret = get_errno(sys_getdents64(arg1, dirp, count));
4128 4128
            if (!is_error(ret)) {
......
4742 4742
        ret = get_errno(0);
4743 4743
        break;
4744 4744
#endif
4745
#if TARGET_LONG_BITS == 32
4745
#if TARGET_ABI_BITS == 32
4746 4746
    case TARGET_NR_fcntl64:
4747 4747
    {
4748 4748
	int cmd;

Also available in: Unified diff