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

Comparing libeio/eio.c (file contents):
Revision 1.9 by root, Mon May 12 00:31:43 2008 UTC vs.
Revision 1.12 by root, Tue May 13 18:54:52 2008 UTC

356 start_thread (); 356 start_thread ();
357} 357}
358 358
359void eio_submit (eio_req *req) 359void eio_submit (eio_req *req)
360{ 360{
361 req->pri += EIO_PRI_BIAS;
362
363 if (req->pri < EIO_PRI_MIN + EIO_PRI_BIAS) req->pri = EIO_PRI_MIN + EIO_PRI_BIAS;
364 if (req->pri > EIO_PRI_MAX + EIO_PRI_BIAS) req->pri = EIO_PRI_MAX + EIO_PRI_BIAS;
365
361 ++nreqs; 366 ++nreqs;
362 367
363 X_LOCK (reqlock); 368 X_LOCK (reqlock);
364 ++nready; 369 ++nready;
365 reqq_push (&req_queue, req); 370 reqq_push (&req_queue, req);
1049 \ 1054 \
1050 req = (eio_req *)calloc (1, sizeof *req); \ 1055 req = (eio_req *)calloc (1, sizeof *req); \
1051 if (!req) \ 1056 if (!req) \
1052 return 0; \ 1057 return 0; \
1053 \ 1058 \
1054 req->type = rtype; \ 1059 req->type = rtype; \
1055 req->pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; \ 1060 req->pri = pri; \
1056 req->finish = cb; \ 1061 req->finish = cb; \
1062 req->data = data; \
1057 req->destroy = eio_api_destroy; 1063 req->destroy = eio_api_destroy;
1058 1064
1059#define SEND eio_submit (req); return req 1065#define SEND eio_submit (req); return req
1060 1066
1061#define PATH \ 1067#define PATH \
1065 { \ 1071 { \
1066 eio_api_destroy (req); \ 1072 eio_api_destroy (req); \
1067 return 0; \ 1073 return 0; \
1068 } 1074 }
1069 1075
1070eio_req *eio_nop (eio_cb cb) 1076#ifndef EIO_NO_WRAPPERS
1077
1078eio_req *eio_nop (int pri, eio_cb cb, void *data)
1071{ 1079{
1072 REQ (EIO_NOP); SEND; 1080 REQ (EIO_NOP); SEND;
1073} 1081}
1074 1082
1075eio_req *eio_busy (double delay, eio_cb cb) 1083eio_req *eio_busy (double delay, int pri, eio_cb cb, void *data)
1076{ 1084{
1077 REQ (EIO_BUSY); req->nv1 = delay; SEND; 1085 REQ (EIO_BUSY); req->nv1 = delay; SEND;
1078} 1086}
1079 1087
1080eio_req *eio_sync (eio_cb cb) 1088eio_req *eio_sync (int pri, eio_cb cb, void *data)
1081{ 1089{
1082 REQ (EIO_SYNC); SEND; 1090 REQ (EIO_SYNC); SEND;
1083} 1091}
1084 1092
1085eio_req *eio_fsync (int fd, eio_cb cb) 1093eio_req *eio_fsync (int fd, int pri, eio_cb cb, void *data)
1086{ 1094{
1087 REQ (EIO_FSYNC); req->int1 = fd; SEND; 1095 REQ (EIO_FSYNC); req->int1 = fd; SEND;
1088} 1096}
1089 1097
1090eio_req *eio_fdatasync (int fd, eio_cb cb) 1098eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data)
1091{ 1099{
1092 REQ (EIO_FDATASYNC); req->int1 = fd; SEND; 1100 REQ (EIO_FDATASYNC); req->int1 = fd; SEND;
1093} 1101}
1094 1102
1095eio_req *eio_close (int fd, eio_cb cb) 1103eio_req *eio_close (int fd, int pri, eio_cb cb, void *data)
1096{ 1104{
1097 REQ (EIO_CLOSE); req->int1 = fd; SEND; 1105 REQ (EIO_CLOSE); req->int1 = fd; SEND;
1098} 1106}
1099 1107
1100eio_req *eio_readahead (int fd, off_t offset, size_t length, eio_cb cb) 1108eio_req *eio_readahead (int fd, off_t offset, size_t length, int pri, eio_cb cb, void *data)
1101{ 1109{
1102 REQ (EIO_READAHEAD); req->int1 = fd; req->offs = offset; req->size = length; SEND; 1110 REQ (EIO_READAHEAD); req->int1 = fd; req->offs = offset; req->size = length; SEND;
1103} 1111}
1104 1112
1105eio_req *eio_read (int fd, void *data, size_t length, off_t offset, eio_cb cb) 1113eio_req *eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data)
1106{ 1114{
1107 REQ (EIO_READ); req->int1 = fd; req->offs = offset; req->size = length; req->ptr2 = data; SEND; 1115 REQ (EIO_READ); req->int1 = fd; req->offs = offset; req->size = length; req->ptr2 = buf; SEND;
1108} 1116}
1109 1117
1110eio_req *eio_write (int fd, void *data, size_t length, off_t offset, eio_cb cb) 1118eio_req *eio_write (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data)
1111{ 1119{
1112 REQ (EIO_WRITE); req->int1 = fd; req->offs = offset; req->size = length; req->ptr2 = data; SEND; 1120 REQ (EIO_WRITE); req->int1 = fd; req->offs = offset; req->size = length; req->ptr2 = buf; SEND;
1113} 1121}
1114 1122
1115eio_req *eio_fstat (int fd, eio_cb cb) 1123eio_req *eio_fstat (int fd, int pri, eio_cb cb, void *data)
1116{ 1124{
1117 REQ (EIO_FSTAT); req->int1 = fd; SEND; 1125 REQ (EIO_FSTAT); req->int1 = fd; SEND;
1118} 1126}
1119 1127
1120eio_req *eio_futime (int fd, double atime, double mtime, eio_cb cb) 1128eio_req *eio_futime (int fd, double atime, double mtime, int pri, eio_cb cb, void *data)
1121{ 1129{
1122 REQ (EIO_FUTIME); req->int1 = fd; req->nv1 = atime; req->nv2 = mtime; SEND; 1130 REQ (EIO_FUTIME); req->int1 = fd; req->nv1 = atime; req->nv2 = mtime; SEND;
1123} 1131}
1124 1132
1125eio_req *eio_ftruncate (int fd, off_t offset, eio_cb cb) 1133eio_req *eio_ftruncate (int fd, off_t offset, int pri, eio_cb cb, void *data)
1126{ 1134{
1127 REQ (EIO_FTRUNCATE); req->int1 = fd; req->offs = offset; SEND; 1135 REQ (EIO_FTRUNCATE); req->int1 = fd; req->offs = offset; SEND;
1128} 1136}
1129 1137
1130eio_req *eio_fchmod (int fd, mode_t mode, eio_cb cb) 1138eio_req *eio_fchmod (int fd, mode_t mode, int pri, eio_cb cb, void *data)
1131{ 1139{
1132 REQ (EIO_FCHMOD); req->int1 = fd; req->int2 = (long)mode; SEND; 1140 REQ (EIO_FCHMOD); req->int1 = fd; req->int2 = (long)mode; SEND;
1133} 1141}
1134 1142
1135eio_req *eio_fchown (int fd, uid_t uid, gid_t gid, eio_cb cb) 1143eio_req *eio_fchown (int fd, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data)
1136{ 1144{
1137 REQ (EIO_FCHOWN); req->int1 = fd; req->int2 = (long)uid; req->int3 = (long)gid; SEND; 1145 REQ (EIO_FCHOWN); req->int1 = fd; req->int2 = (long)uid; req->int3 = (long)gid; SEND;
1138} 1146}
1139 1147
1140eio_req *eio_dup2 (int fd, int fd2, eio_cb cb) 1148eio_req *eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data)
1141{ 1149{
1142 REQ (EIO_DUP2); req->int1 = fd; req->int2 = fd2; SEND; 1150 REQ (EIO_DUP2); req->int1 = fd; req->int2 = fd2; SEND;
1143} 1151}
1144 1152
1145eio_req *eio_sendfile (int out_fd, int in_fd, off_t in_offset, size_t length, eio_cb cb) 1153eio_req *eio_sendfile (int out_fd, int in_fd, off_t in_offset, size_t length, int pri, eio_cb cb, void *data)
1146{ 1154{
1147 REQ (EIO_SENDFILE); req->int1 = out_fd; req->int2 = in_fd; req->offs = in_offset; req->size = length; SEND; 1155 REQ (EIO_SENDFILE); req->int1 = out_fd; req->int2 = in_fd; req->offs = in_offset; req->size = length; SEND;
1148} 1156}
1149 1157
1150eio_req *eio_open (const char *path, int flags, mode_t mode, eio_cb cb) 1158eio_req *eio_open (const char *path, int flags, mode_t mode, int pri, eio_cb cb, void *data)
1151{ 1159{
1152 REQ (EIO_OPEN); PATH; req->int1 = flags; req->int2 = (long)mode; SEND; 1160 REQ (EIO_OPEN); PATH; req->int1 = flags; req->int2 = (long)mode; SEND;
1153} 1161}
1154 1162
1155eio_req *eio_utime (const char *path, double atime, double mtime, eio_cb cb) 1163eio_req *eio_utime (const char *path, double atime, double mtime, int pri, eio_cb cb, void *data)
1156{ 1164{
1157 REQ (EIO_UTIME); PATH; req->nv1 = atime; req->nv2 = mtime; SEND; 1165 REQ (EIO_UTIME); PATH; req->nv1 = atime; req->nv2 = mtime; SEND;
1158} 1166}
1159 1167
1160eio_req *eio_truncate (const char *path, off_t offset, eio_cb cb) 1168eio_req *eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data)
1161{ 1169{
1162 REQ (EIO_TRUNCATE); PATH; req->offs = offset; SEND; 1170 REQ (EIO_TRUNCATE); PATH; req->offs = offset; SEND;
1163} 1171}
1164 1172
1165eio_req *eio_chown (const char *path, uid_t uid, gid_t gid, eio_cb cb) 1173eio_req *eio_chown (const char *path, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data)
1166{ 1174{
1167 REQ (EIO_CHOWN); PATH; req->int2 = (long)uid; req->int3 = (long)gid; SEND; 1175 REQ (EIO_CHOWN); PATH; req->int2 = (long)uid; req->int3 = (long)gid; SEND;
1168} 1176}
1169 1177
1170eio_req *eio_chmod (const char *path, mode_t mode, eio_cb cb) 1178eio_req *eio_chmod (const char *path, mode_t mode, int pri, eio_cb cb, void *data)
1171{ 1179{
1172 REQ (EIO_CHMOD); PATH; req->int2 = (long)mode; SEND; 1180 REQ (EIO_CHMOD); PATH; req->int2 = (long)mode; SEND;
1173} 1181}
1174 1182
1175eio_req *eio_mkdir (const char *path, mode_t mode, eio_cb cb) 1183eio_req *eio_mkdir (const char *path, mode_t mode, int pri, eio_cb cb, void *data)
1176{ 1184{
1177 REQ (EIO_MKDIR); PATH; req->int2 = (long)mode; SEND; 1185 REQ (EIO_MKDIR); PATH; req->int2 = (long)mode; SEND;
1178} 1186}
1179 1187
1180static eio_req * 1188static eio_req *
1181eio__1path (int type, const char *path, eio_cb cb) 1189eio__1path (int type, const char *path, int pri, eio_cb cb, void *data)
1182{ 1190{
1183 REQ (type); PATH; SEND; 1191 REQ (type); PATH; SEND;
1184} 1192}
1185 1193
1186eio_req *eio_readlink (const char *path, eio_cb cb) 1194eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data)
1187{ 1195{
1188 return eio__1path (EIO_READLINK, path, cb); 1196 return eio__1path (EIO_READLINK, path, pri, cb, data);
1189} 1197}
1190 1198
1191eio_req *eio_stat (const char *path, eio_cb cb) 1199eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data)
1192{ 1200{
1193 return eio__1path (EIO_STAT, path, cb); 1201 return eio__1path (EIO_STAT, path, pri, cb, data);
1194} 1202}
1195 1203
1196eio_req *eio_lstat (const char *path, eio_cb cb) 1204eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data)
1197{ 1205{
1198 return eio__1path (EIO_LSTAT, path, cb); 1206 return eio__1path (EIO_LSTAT, path, pri, cb, data);
1199} 1207}
1200 1208
1201eio_req *eio_unlink (const char *path, eio_cb cb) 1209eio_req *eio_unlink (const char *path, int pri, eio_cb cb, void *data)
1202{ 1210{
1203 return eio__1path (EIO_UNLINK, path, cb); 1211 return eio__1path (EIO_UNLINK, path, pri, cb, data);
1204} 1212}
1205 1213
1206eio_req *eio_rmdir (const char *path, eio_cb cb) 1214eio_req *eio_rmdir (const char *path, int pri, eio_cb cb, void *data)
1207{ 1215{
1208 return eio__1path (EIO_RMDIR, path, cb); 1216 return eio__1path (EIO_RMDIR, path, pri, cb, data);
1209} 1217}
1210 1218
1211eio_req *eio_readdir (const char *path, eio_cb cb) 1219eio_req *eio_readdir (const char *path, int pri, eio_cb cb, void *data)
1212{ 1220{
1213 return eio__1path (EIO_READDIR, path, cb); 1221 return eio__1path (EIO_READDIR, path, pri, cb, data);
1214} 1222}
1215 1223
1216eio_req *eio_mknod (const char *path, mode_t mode, dev_t dev, eio_cb cb) 1224eio_req *eio_mknod (const char *path, mode_t mode, dev_t dev, int pri, eio_cb cb, void *data)
1217{ 1225{
1218 REQ (EIO_MKNOD); PATH; req->int2 = (long)mode; req->int2 = (long)dev; SEND; 1226 REQ (EIO_MKNOD); PATH; req->int2 = (long)mode; req->int2 = (long)dev; SEND;
1219} 1227}
1220 1228
1221static eio_req * 1229static eio_req *
1222eio__2path (int type, const char *path, const char *new_path, eio_cb cb) 1230eio__2path (int type, const char *path, const char *new_path, int pri, eio_cb cb, void *data)
1223{ 1231{
1224 REQ (type); PATH; 1232 REQ (type); PATH;
1225 1233
1226 req->flags |= EIO_FLAG_PTR2_FREE; 1234 req->flags |= EIO_FLAG_PTR2_FREE;
1227 req->ptr2 = strdup (new_path); 1235 req->ptr2 = strdup (new_path);
1232 } 1240 }
1233 1241
1234 SEND; 1242 SEND;
1235} 1243}
1236 1244
1237eio_req *eio_link (const char *path, const char *new_path, eio_cb cb) 1245eio_req *eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data)
1238{ 1246{
1239 return eio__2path (EIO_LINK, path, new_path, cb); 1247 return eio__2path (EIO_LINK, path, new_path, pri, cb, data);
1240} 1248}
1241 1249
1242eio_req *eio_symlink (const char *path, const char *new_path, eio_cb cb) 1250eio_req *eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data)
1243{ 1251{
1244 return eio__2path (EIO_SYMLINK, path, new_path, cb); 1252 return eio__2path (EIO_SYMLINK, path, new_path, pri, cb, data);
1245} 1253}
1246 1254
1247eio_req *eio_rename (const char *path, const char *new_path, eio_cb cb) 1255eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data)
1248{ 1256{
1249 return eio__2path (EIO_RENAME, path, new_path, cb); 1257 return eio__2path (EIO_RENAME, path, new_path, pri, cb, data);
1258}
1259
1260#endif
1261
1262eio_req *eio_grp (eio_cb cb, void *data)
1263{
1264 const int pri = EIO_PRI_MAX;
1265
1266 REQ (EIO_GROUP); SEND;
1250} 1267}
1251 1268
1252#undef REQ 1269#undef REQ
1253#undef PATH 1270#undef PATH
1254#undef SEND 1271#undef SEND

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines