From: Arnaud Giersch Date: Mon, 18 Nov 2013 21:19:00 +0000 (+0100) Subject: Use unsigned long long instead of uint64_t for sg_size_t. X-Git-Tag: v3_11_beta~278 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/cb462a8ced7fd3a3fc92e6990fb23514d4591902 Use unsigned long long instead of uint64_t for sg_size_t. It's at least 64bits long, and the printf/scanf format is prettier/easier to write. --- diff --git a/examples/msg/io/file.c b/examples/msg/io/file.c index 3f1ea65e40..11a9210aea 100644 --- a/examples/msg/io/file.c +++ b/examples/msg/io/file.c @@ -24,7 +24,6 @@ #include #include "msg/msg.h" #include "surf/surf_private.h" -#include "inttypes.h" int host(int argc, char *argv[]); @@ -53,13 +52,13 @@ int host(int argc, char *argv[]) XBT_INFO("\tOpen file '%s'",file->fullname); read = MSG_file_read(file, 10000000); // Read for 10MB - XBT_INFO("\tHave read %" PRIu64 " on %s",read,file->fullname); + XBT_INFO("\tHave read %llu on %s",read,file->fullname); write = MSG_file_write(file, 100000); // Write for 100KB - XBT_INFO("\tHave written %" PRIu64 " on %s",write,file->fullname); + XBT_INFO("\tHave written %llu on %s",write,file->fullname); read = MSG_file_read(file, 110000); // Read for 110KB - XBT_INFO("\tHave read %" PRIu64 " on %s (of size %" PRIu64 ")",read,file->fullname, + XBT_INFO("\tHave read %llu on %s (of size %llu)",read,file->fullname, MSG_file_get_size(file)); XBT_INFO("\tClose file '%s'",file->fullname); diff --git a/examples/msg/io/file_unlink.c b/examples/msg/io/file_unlink.c index 42e3224a77..bb74c9f02b 100644 --- a/examples/msg/io/file_unlink.c +++ b/examples/msg/io/file_unlink.c @@ -21,7 +21,6 @@ #include #include "msg/msg.h" #include "surf/surf_private.h" -#include "inttypes.h" int host(int argc, char *argv[]); @@ -48,7 +47,7 @@ int host(int argc, char *argv[]) // Write into the new file write = MSG_file_write(file,100000); // Write for 100Ko - XBT_INFO("\tHave written %" PRIu64 " on %s",write,file->fullname); + XBT_INFO("\tHave written %llu on %s",write,file->fullname); // Close the file XBT_INFO("\tClose file '%s'",file->fullname); diff --git a/examples/msg/io/storage.c b/examples/msg/io/storage.c index 2b8eafe5f5..b422797431 100644 --- a/examples/msg/io/storage.c +++ b/examples/msg/io/storage.c @@ -22,9 +22,6 @@ #include "xbt/log.h" #include "xbt/dict.h" - /* To use PRIu64 format specifier for printing uint64_t (sg_size_t) */ -#include - XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation"); static int host(int argc, char *argv[]){ @@ -51,9 +48,9 @@ static int host(int argc, char *argv[]){ sg_size_t used_size = MSG_storage_get_used_size(mount_name); sg_size_t size = MSG_storage_get_size(storage); - XBT_INFO("Total size: %"PRIu64" bytes", size); - XBT_INFO("Free size: %"PRIu64" bytes", free_size); - XBT_INFO("Used size: %"PRIu64" bytes", used_size); + XBT_INFO("Total size: %llu bytes", size); + XBT_INFO("Free size: %llu bytes", free_size); + XBT_INFO("Used size: %llu bytes", used_size); } xbt_dict_free(&storage_list); @@ -68,22 +65,22 @@ static int host(int argc, char *argv[]){ // Open an non-existing file amounts to create it! file = MSG_file_open(mount, file_name, NULL); write = MSG_file_write(file, 200000); // Write 200,000 bytes - XBT_INFO("Create a %"PRIu64" bytes file named '%s' on /sd1", write, file_name); + XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, file_name); MSG_file_dump(file); // check that sizes have changed - XBT_INFO("Free size: %"PRIu64" bytes", MSG_storage_get_free_size("/home")); - XBT_INFO("Used size: %"PRIu64" bytes", MSG_storage_get_used_size("/home")); + XBT_INFO("Free size: %llu bytes", MSG_storage_get_free_size("/home")); + XBT_INFO("Used size: %llu bytes", MSG_storage_get_used_size("/home")); // Now retrieve the size of created file and read it completely file_size = MSG_file_get_size(file); read = MSG_file_read(file, file_size); - XBT_INFO("Read %"PRIu64" bytes on %s", read, file_name); + XBT_INFO("Read %llu bytes on %s", read, file_name); // Now write 100,000 more bytes in tmp/data.txt write = MSG_file_write(file, 100000); // Write 100,000 bytes - XBT_INFO("Write %"PRIu64" more bytes on %s", write, file_name); + XBT_INFO("Write %llu more bytes on %s", write, file_name); MSG_file_dump(file); MSG_file_close(file); @@ -122,7 +119,7 @@ static int host(int argc, char *argv[]){ xbt_dict_foreach(contents, curs, mountname, content){ XBT_INFO("Print the content of mount point: %s",mountname); xbt_dict_foreach(content,curs2,path,size){ - XBT_INFO("%s size: %"PRIu64" bytes", path,*((sg_size_t*)size)); + XBT_INFO("%s size: %llu bytes", path,*((sg_size_t*)size)); } xbt_dict_free(&content); } diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h index 9358eba867..7e0e3fe02d 100644 --- a/include/simgrid/platf.h +++ b/include/simgrid/platf.h @@ -10,8 +10,6 @@ #define SG_PLATF_H #include -#define __STDC_FORMAT_MACROS -#include typedef void *sg_routing_link_t; /* FIXME:The actual type is model-dependent so use void* instead*/ typedef struct RoutingEdge *sg_routing_edge_t; @@ -96,7 +94,7 @@ static inline char* sg_storage_name(sg_storage_t storage) { return storage->key; } /* Type for any simgrid size size */ -typedef uint64_t sg_size_t; +typedef unsigned long long sg_size_t; /* * Platform creation functions. Instead of passing 123 arguments to the creation functions diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index 0ce1bc7717..fcb8f766a3 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -6,7 +6,6 @@ #include "msg_private.h" #include "xbt/log.h" -#include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_io, msg, "Logging specific to MSG (io)"); @@ -71,7 +70,7 @@ void MSG_file_dump (msg_file_t fd){ __MSG_file_get_info(fd); XBT_INFO("File Descriptor information:\n" "\t\tFull name: '%s'\n" - "\t\tSize: %" PRIu64 "\n" + "\t\tSize: %llu\n" "\t\tMount point: '%s'\n" "\t\tStorage Id: '%s'\n" "\t\tStorage Type: '%s'\n" diff --git a/src/msg/msg_vm.c b/src/msg/msg_vm.c index fef1c6e7f4..72d331b67a 100644 --- a/src/msg/msg_vm.c +++ b/src/msg/msg_vm.c @@ -834,9 +834,9 @@ static void send_migration_data(const char *vm_name, const char *src_pm_name, co if (stage == 2){ - XBT_DEBUG("mig-stage%d.%d: sent %" PRIu64 " duration %f actual_speed %f (target %f) cpu %f", stage, stage2_round, size, duration, actual_speed, mig_speed, cpu_utilization);} + XBT_DEBUG("mig-stage%d.%d: sent %llu duration %f actual_speed %f (target %f) cpu %f", stage, stage2_round, size, duration, actual_speed, mig_speed, cpu_utilization);} else{ - XBT_DEBUG("mig-stage%d: sent %" PRIu64 " duration %f actual_speed %f (target %f) cpu %f", stage, size, duration, actual_speed, mig_speed, cpu_utilization); + XBT_DEBUG("mig-stage%d: sent %llu duration %f actual_speed %f (target %f) cpu %f", stage, size, duration, actual_speed, mig_speed, cpu_utilization); } xbt_free(task_name); diff --git a/src/surf/storage.cpp b/src/surf/storage.cpp index 72ed082b31..82b2d4a943 100644 --- a/src/surf/storage.cpp +++ b/src/surf/storage.cpp @@ -148,7 +148,7 @@ static xbt_dict_t parse_storage_content(char *filename, sg_size_t *used_size) while ((read = xbt_getline(&line, &len, file)) != -1) { if (read){ - if(sscanf(line,"%s %" SCNu64, path, &size) == 2) { + if(sscanf(line,"%s %llu", path, &size) == 2) { *used_size += size; sg_size_t *psize = xbt_new(sg_size_t, 1); *psize = size; @@ -427,7 +427,7 @@ xbt_dict_t Storage::parseContent(char *filename) while ((read = xbt_getline(&line, &len, file)) != -1) { if (read){ - if(sscanf(line,"%s %" SCNu64, path, &size) == 2) { + if(sscanf(line,"%s %llu", path, &size) == 2) { m_usedSize += size; sg_size_t *psize = xbt_new(sg_size_t, 1); *psize = size; @@ -555,7 +555,7 @@ StorageActionPtr StorageLmm::open(const char* mount, const char* path) StorageActionPtr StorageLmm::close(surf_file_t fd) { char *filename = fd->name; - XBT_DEBUG("\tClose file '%s' size '%" PRIu64 "'", filename, fd->size); + XBT_DEBUG("\tClose file '%s' size '%llu'", filename, fd->size); // unref write actions from storage StorageActionLmmPtr write_action; unsigned int i; @@ -583,7 +583,7 @@ StorageActionPtr StorageLmm::read(surf_file_t fd, sg_size_t size) StorageActionPtr StorageLmm::write(surf_file_t fd, sg_size_t size) { char *filename = fd->name; - XBT_DEBUG("\tWrite file '%s' size '%" PRIu64 "/%" PRIu64 "'",filename,size,fd->size); + XBT_DEBUG("\tWrite file '%s' size '%llu/%llu'",filename,size,fd->size); StorageActionLmmPtr action = new StorageActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, WRITE); action->p_file = fd; @@ -604,7 +604,7 @@ void StorageLmm::rename(const char *src, const char *dest) if (psize){// src file exists xbt_dict_remove(p_content, src); xbt_dict_set(p_content, dest, new_psize,NULL); - XBT_DEBUG("Change file name from %s to %s, size '%" PRIu64 "'",src, dest, *psize); + XBT_DEBUG("Change file name from %s to %s, size '%llu'",src, dest, *psize); } else XBT_DEBUG("File %s doesn't exist",src); @@ -636,7 +636,7 @@ sg_size_t StorageLmm::getSize(){ StorageActionLmm::StorageActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type) : Action(model, cost, failed), ActionLmm(model, cost, failed), StorageAction(model, cost, failed, storage, type) { - XBT_IN("(%s,%" PRIu64, storage->m_name, cost); + XBT_IN("(%s,%g", storage->m_name, cost); p_variable = lmm_variable_new(p_model->p_maxminSystem, this, 1.0, -1.0 , 3); // Must be less than the max bandwidth for all actions diff --git a/teshsuite/msg/storage/storage_basic.c b/teshsuite/msg/storage/storage_basic.c index d2c12975c0..8b501979bf 100644 --- a/teshsuite/msg/storage/storage_basic.c +++ b/teshsuite/msg/storage/storage_basic.c @@ -1,6 +1,5 @@ #include "msg/msg.h" #include "xbt/log.h" -#include "inttypes.h" XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation"); @@ -35,8 +34,8 @@ void storage_info(msg_host_t host) sg_size_t free_size = MSG_storage_get_free_size(mount_name); sg_size_t used_size = MSG_storage_get_used_size(mount_name); - XBT_INFO("Free size: %" PRIu64 " bytes", free_size); - XBT_INFO("Used size: %" PRIu64 " bytes", used_size); + XBT_INFO("Free size: %llu bytes", free_size); + XBT_INFO("Used size: %llu bytes", used_size); storage = MSG_storage_get_by_name(storage_name); display_storage_properties(storage); @@ -64,7 +63,7 @@ int hsm_put(const char *remote_host, const char *src, const char *dest){ sg_size_t read_size = read_local_file(src); // Send file - XBT_INFO("%s sends %" PRIu64 " to %s",MSG_host_get_name(MSG_host_self()),read_size,remote_host); + XBT_INFO("%s sends %llu to %s",MSG_host_get_name(MSG_host_self()),read_size,remote_host); msg_task_t to_execute = MSG_task_create((const char*)"hsm_put", 0, (double) read_size, (void*)dest); MSG_task_send(to_execute, remote_host); @@ -87,7 +86,7 @@ sg_size_t read_local_file(const char *src) file_size = MSG_file_get_size(file); read = MSG_file_read(file, file_size); - XBT_INFO("%s has read %" PRIu64 " on %s",MSG_host_get_name(MSG_host_self()),read,src); + XBT_INFO("%s has read %llu on %s",MSG_host_get_name(MSG_host_self()),read,src); MSG_file_close(file); return read; @@ -131,7 +130,7 @@ void display_storage_content(msg_storage_t storage){ xbt_dict_t content = MSG_storage_get_content(storage); if (content){ xbt_dict_foreach(content, cursor, file, psize) - XBT_INFO("%s size: %" PRIu64 " bytes", file, *psize); + XBT_INFO("%s size: %llu bytes", file, *psize); } else { XBT_INFO("No content."); } diff --git a/tools/spell/sg_stopwords.txt b/tools/spell/sg_stopwords.txt index 2c7cf96d9e..c87cff166c 100644 --- a/tools/spell/sg_stopwords.txt +++ b/tools/spell/sg_stopwords.txt @@ -3440,7 +3440,6 @@ printTasks prio prioritarily PriorityClass -PRIu priv PRN PRNG