syscall_emul.hh (12018:eb31fcce5ef7) syscall_emul.hh (12032:d218c2fe9440)
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * Copyright (c) 2015 Advanced Micro Devices, Inc.
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

--- 415 unchanged lines hidden (view full) ---

424 typedef struct stat64 hst_stat64;
425#endif
426
427//// Helper function to convert a host stat buffer to a target stat
428//// buffer. Also copies the target buffer out to the simulated
429//// memory space. Used by stat(), fstat(), and lstat().
430
431template <typename target_stat, typename host_stat>
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * Copyright (c) 2015 Advanced Micro Devices, Inc.
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

--- 415 unchanged lines hidden (view full) ---

424 typedef struct stat64 hst_stat64;
425#endif
426
427//// Helper function to convert a host stat buffer to a target stat
428//// buffer. Also copies the target buffer out to the simulated
429//// memory space. Used by stat(), fstat(), and lstat().
430
431template <typename target_stat, typename host_stat>
432static void
432void
433convertStatBuf(target_stat &tgt, host_stat *host, bool fakeTTY = false)
434{
435 using namespace TheISA;
436
437 if (fakeTTY)
438 tgt->st_dev = 0xA;
439 else
440 tgt->st_dev = host->st_dev;

--- 32 unchanged lines hidden (view full) ---

473 tgt->st_blksize = TheISA::htog(tgt->st_blksize);
474 tgt->st_blocks = host->st_blocks;
475 tgt->st_blocks = TheISA::htog(tgt->st_blocks);
476}
477
478// Same for stat64
479
480template <typename target_stat, typename host_stat64>
433convertStatBuf(target_stat &tgt, host_stat *host, bool fakeTTY = false)
434{
435 using namespace TheISA;
436
437 if (fakeTTY)
438 tgt->st_dev = 0xA;
439 else
440 tgt->st_dev = host->st_dev;

--- 32 unchanged lines hidden (view full) ---

473 tgt->st_blksize = TheISA::htog(tgt->st_blksize);
474 tgt->st_blocks = host->st_blocks;
475 tgt->st_blocks = TheISA::htog(tgt->st_blocks);
476}
477
478// Same for stat64
479
480template <typename target_stat, typename host_stat64>
481static void
481void
482convertStat64Buf(target_stat &tgt, host_stat64 *host, bool fakeTTY = false)
483{
484 using namespace TheISA;
485
486 convertStatBuf<target_stat, host_stat64>(tgt, host, fakeTTY);
487#if defined(STAT_HAVE_NSEC)
488 tgt->st_atime_nsec = host->st_atime_nsec;
489 tgt->st_atime_nsec = TheISA::htog(tgt->st_atime_nsec);

--- 5 unchanged lines hidden (view full) ---

495 tgt->st_atime_nsec = 0;
496 tgt->st_mtime_nsec = 0;
497 tgt->st_ctime_nsec = 0;
498#endif
499}
500
501// Here are a couple of convenience functions
502template<class OS>
482convertStat64Buf(target_stat &tgt, host_stat64 *host, bool fakeTTY = false)
483{
484 using namespace TheISA;
485
486 convertStatBuf<target_stat, host_stat64>(tgt, host, fakeTTY);
487#if defined(STAT_HAVE_NSEC)
488 tgt->st_atime_nsec = host->st_atime_nsec;
489 tgt->st_atime_nsec = TheISA::htog(tgt->st_atime_nsec);

--- 5 unchanged lines hidden (view full) ---

495 tgt->st_atime_nsec = 0;
496 tgt->st_mtime_nsec = 0;
497 tgt->st_ctime_nsec = 0;
498#endif
499}
500
501// Here are a couple of convenience functions
502template<class OS>
503static void
503void
504copyOutStatBuf(SETranslatingPortProxy &mem, Addr addr,
505 hst_stat *host, bool fakeTTY = false)
506{
507 typedef TypedBufferArg<typename OS::tgt_stat> tgt_stat_buf;
508 tgt_stat_buf tgt(addr);
509 convertStatBuf<tgt_stat_buf, hst_stat>(tgt, host, fakeTTY);
510 tgt.copyOut(mem);
511}
512
513template<class OS>
504copyOutStatBuf(SETranslatingPortProxy &mem, Addr addr,
505 hst_stat *host, bool fakeTTY = false)
506{
507 typedef TypedBufferArg<typename OS::tgt_stat> tgt_stat_buf;
508 tgt_stat_buf tgt(addr);
509 convertStatBuf<tgt_stat_buf, hst_stat>(tgt, host, fakeTTY);
510 tgt.copyOut(mem);
511}
512
513template<class OS>
514static void
514void
515copyOutStat64Buf(SETranslatingPortProxy &mem, Addr addr,
516 hst_stat64 *host, bool fakeTTY = false)
517{
518 typedef TypedBufferArg<typename OS::tgt_stat64> tgt_stat_buf;
519 tgt_stat_buf tgt(addr);
520 convertStat64Buf<tgt_stat_buf, hst_stat64>(tgt, host, fakeTTY);
521 tgt.copyOut(mem);
522}
523
524template <class OS>
515copyOutStat64Buf(SETranslatingPortProxy &mem, Addr addr,
516 hst_stat64 *host, bool fakeTTY = false)
517{
518 typedef TypedBufferArg<typename OS::tgt_stat64> tgt_stat_buf;
519 tgt_stat_buf tgt(addr);
520 convertStat64Buf<tgt_stat_buf, hst_stat64>(tgt, host, fakeTTY);
521 tgt.copyOut(mem);
522}
523
524template <class OS>
525static void
525void
526copyOutStatfsBuf(SETranslatingPortProxy &mem, Addr addr,
527 hst_statfs *host)
528{
529 TypedBufferArg<typename OS::tgt_statfs> tgt(addr);
530
531 tgt->f_type = TheISA::htog(host->f_type);
532#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
533 tgt->f_bsize = TheISA::htog(host->f_iosize);

--- 1478 unchanged lines hidden ---
526copyOutStatfsBuf(SETranslatingPortProxy &mem, Addr addr,
527 hst_statfs *host)
528{
529 TypedBufferArg<typename OS::tgt_statfs> tgt(addr);
530
531 tgt->f_type = TheISA::htog(host->f_type);
532#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
533 tgt->f_bsize = TheISA::htog(host->f_iosize);

--- 1478 unchanged lines hidden ---