ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libeio/eio.c
(Generate patch)

Comparing libeio/eio.c (file contents):
Revision 1.116 by root, Tue Mar 27 19:27:35 2012 UTC vs.
Revision 1.117 by root, Sun Apr 1 17:22:42 2012 UTC

1/* 1/*
2 * libeio implementation 2 * libeio implementation
3 * 3 *
4 * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libeio@schmorp.de> 4 * Copyright (c) 2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann <libeio@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
1382 return 0; 1382 return 0;
1383} 1383}
1384 1384
1385/*****************************************************************************/ 1385/*****************************************************************************/
1386/* requests implemented outside eio_execute, because they are so large */ 1386/* requests implemented outside eio_execute, because they are so large */
1387
1388static void
1389eio__lseek (eio_req *req)
1390{
1391 /* this usually gets optimised away completely, or your compiler sucks, */
1392 /* or the whence constants really are not 0, 1, 2 */
1393 int whence = req->int2 == EIO_SEEK_SET ? SEEK_SET
1394 : req->int2 == EIO_SEEK_CUR ? SEEK_CUR
1395 : req->int2 == EIO_SEEK_END ? SEEK_END
1396 : req->int2;
1397
1398 req->offs = lseek (req->int1, req->offs, whence);
1399 req->result = req->offs == (off_t)-1 ? -1 : 0;
1400}
1387 1401
1388/* result will always end up in tmpbuf, there is always space for adding a 0-byte */ 1402/* result will always end up in tmpbuf, there is always space for adding a 0-byte */
1389static int 1403static int
1390eio__realpath (struct tmpbuf *tmpbuf, eio_wd wd, const char *path) 1404eio__realpath (struct tmpbuf *tmpbuf, eio_wd wd, const char *path)
1391{ 1405{
2315 req->result = req->wd == EIO_INVALID_WD ? -1 : 0; 2329 req->result = req->wd == EIO_INVALID_WD ? -1 : 0;
2316 break; 2330 break;
2317 case EIO_WD_CLOSE: req->result = 0; 2331 case EIO_WD_CLOSE: req->result = 0;
2318 eio_wd_close_sync (req->wd); break; 2332 eio_wd_close_sync (req->wd); break;
2319 2333
2334 case EIO_SEEK: eio__lseek (req); break;
2320 case EIO_READ: ALLOC (req->size); 2335 case EIO_READ: ALLOC (req->size);
2321 req->result = req->offs >= 0 2336 req->result = req->offs >= 0
2322 ? pread (req->int1, req->ptr2, req->size, req->offs) 2337 ? pread (req->int1, req->ptr2, req->size, req->offs)
2323 : read (req->int1, req->ptr2, req->size); break; 2338 : read (req->int1, req->ptr2, req->size); break;
2324 case EIO_WRITE: req->result = req->offs >= 0 2339 case EIO_WRITE: req->result = req->offs >= 0
2570eio_req *eio_readahead (int fd, off_t offset, size_t length, int pri, eio_cb cb, void *data) 2585eio_req *eio_readahead (int fd, off_t offset, size_t length, int pri, eio_cb cb, void *data)
2571{ 2586{
2572 REQ (EIO_READAHEAD); req->int1 = fd; req->offs = offset; req->size = length; SEND; 2587 REQ (EIO_READAHEAD); req->int1 = fd; req->offs = offset; req->size = length; SEND;
2573} 2588}
2574 2589
2590eio_req *eio_seek (int fd, off_t offset, int whence, int pri, eio_cb cb, void *data)
2591{
2592 REQ (EIO_SEEK); req->int1 = fd; req->offs = offset; req->int2 = whence; SEND;
2593}
2594
2575eio_req *eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data) 2595eio_req *eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data)
2576{ 2596{
2577 REQ (EIO_READ); req->int1 = fd; req->offs = offset; req->size = length; req->ptr2 = buf; SEND; 2597 REQ (EIO_READ); req->int1 = fd; req->offs = offset; req->size = length; req->ptr2 = buf; SEND;
2578} 2598}
2579 2599

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines