]> rtime.felk.cvut.cz Git - frescor/fna.git/commitdiff
debug function
authorsangorrin <sangorrin@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Mon, 29 Oct 2007 18:17:23 +0000 (18:17 +0000)
committersangorrin <sangorrin@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Mon, 29 Oct 2007 18:17:23 +0000 (18:17 +0000)
git-svn-id: http://www.frescor.org/private/svn/frescor/fna/trunk@821 35b4ef3e-fd22-0410-ab77-dab3279adceb

src_unix/unix_fna.c

index b3e3c76f0a95dd7ad15fb65e76ea6a7bfc4bdabd..670fe5bb32785b1789585052927611ab28dc6372 100644 (file)
 #include <sys/socket.h>
 #include <sys/un.h> /* struct sockaddr_un */
 
-#if 1
+/* DEBUGGING FLAGS and MACROS */
 #include <stdio.h>
-#define DEBUG(x,args...) printf("%s: " x, __func__ , ##args)
-#else
-#define DEBUG(x,args...)
-#endif
+#define DEBUG(enable,x,args...) if(enable) printf("\t>> Called %s: " x, __func__ , ##args)
+#define DBG_UNIX_FNA_NOT_IMPLEMENTED true
 
 //////////////////////////////////////////////////////////////////////
 //           INITIALIZATION
@@ -125,7 +123,7 @@ char *the_unix_socket_paths[MX_UNIX_SOCKET_PATHS] = {
 
 int unix_fna_init(const frsh_resource_id_t resource_id)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -146,7 +144,7 @@ int unix_fna_contract_negotiate(const frsh_resource_id_t resource_id,
         struct sockaddr_un sender_addr;
         int unix_path_index;
 
-        DEBUG("Creating and binding the unix socket\n");
+        DEBUG(true, "Creating and binding the unix socket\n");
 
         sock = socket(AF_UNIX, SOCK_DGRAM, 0);
         assert(sock >= 0);
@@ -174,7 +172,7 @@ int unix_fna_contract_renegotiate_sync(const frsh_resource_id_t resource_id,
                                        const fna_vres_id_t vres,
                                        const frsh_contract_t *new_contract)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -189,7 +187,7 @@ int unix_fna_contract_renegotiate_async(const frsh_resource_id_t resource_id,
                                         frsh_signal_t signal_to_notify,
                                         frsh_signal_info_t signal_info)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -202,7 +200,7 @@ int unix_fna_vres_get_renegotiation_status(const frsh_resource_id_t resource_id,
                                            const fna_vres_id_t vres,
                                            frsh_renegotiation_status_t *renegotiation_status)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -214,7 +212,7 @@ int unix_fna_vres_get_renegotiation_status(const frsh_resource_id_t resource_id,
 int unix_fna_vres_destroy(const frsh_resource_id_t resource_id,
                           const fna_vres_id_t vres)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -227,7 +225,7 @@ int unix_fna_vres_get_contract(const frsh_resource_id_t resource_id,
                                const fna_vres_id_t vres,
                                frsh_contract_t *contract)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -240,7 +238,7 @@ int unix_fna_vres_get_usage(const frsh_resource_id_t resource_id,
                             const fna_vres_id_t vres,
                             struct timespec *usage)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -253,7 +251,7 @@ int unix_fna_vres_get_remaining_budget(const frsh_resource_id_t resource_id,
                                        const fna_vres_id_t vres,
                                        struct timespec *remaining_budget)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -267,7 +265,7 @@ int unix_fna_vres_get_budget_and_period(const frsh_resource_id_t resource_id,
                                         struct timespec *budget,
                                         struct timespec *period)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -284,7 +282,7 @@ int unix_fna_resource_get_capacity(const frsh_resource_id_t resource_id,
                                    const int importance,
                                    uint32_t *capacity)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -297,7 +295,7 @@ int unix_fna_resource_get_total_weight(const frsh_resource_id_t resource_id,
                                        const int importance,
                                        int *total_weight)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -311,7 +309,7 @@ int unix_fna_vres_decrease_capacity(const frsh_resource_id_t resource_id,
                                     const struct timespec new_budget,
                                     const struct timespec new_period)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -328,7 +326,7 @@ int unix_fna_send_sync(const fna_endpoint_data_t *endpoint,
                        const void *msg,
                        const size_t size)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -345,7 +343,7 @@ int unix_fna_send_async(const fna_endpoint_data_t *endpoint,
         struct sockaddr_un receiver_addr;
         ssize_t sent_bytes;
 
-        DEBUG("send async\n");
+        DEBUG(true, "send async\n");
 
         assert(endpoint->is_bound);
 
@@ -381,7 +379,7 @@ int unix_fna_receive_sync(const fna_endpoint_data_t *endpoint,
         ssize_t recv_bytes;
         socklen_t from_len;
 
-        DEBUG("receive sync\n");
+        DEBUG(true, "receive sync\n");
 
         from_len = sizeof(sender_addr);
         recv_bytes = recvfrom(endpoint->vres, /* the socket */
@@ -410,7 +408,7 @@ int unix_fna_receive_async(const fna_endpoint_data_t *endpoint,
                            size_t *received_bytes,
                            frsh_network_address_t *from)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -424,7 +422,7 @@ int unix_fna_send_endpoint_get_status(const fna_endpoint_data_t *endpoint,
                                       frsh_endpoint_network_status_t *network_status,
                                       frsh_protocol_status_t *protocol_status)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -438,7 +436,7 @@ int unix_fna_receive_endpoint_created(fna_endpoint_data_t *endpoint)
         struct sockaddr_un receiver_addr;
         int unix_path_index;
 
-        DEBUG("creating the socket to receive\n");
+        DEBUG(true, "creating the socket to receive\n");
 
         sock = socket(AF_UNIX, SOCK_DGRAM, 0);
         assert(sock >= 0);
@@ -467,7 +465,7 @@ int unix_fna_receive_endpoint_get_status(const fna_endpoint_data_t *endpoint,
                                          frsh_endpoint_network_status_t *network_status,
                                          frsh_protocol_status_t *protocol_status)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -484,7 +482,7 @@ int unix_fna_network_get_max_message_size(const frsh_resource_id_t resource_id,
                                           const frsh_network_address_t destination,
                                           size_t *max_size)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -497,7 +495,9 @@ int unix_fna_network_bytes_to_budget(const frsh_resource_id_t resource_id,
                                      const size_t nbytes,
                                      struct timespec *budget)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(true, "let's put 1 microsecond\n");
+        budget->tv_sec  = 0;
+        budget->tv_nsec = 1000;
         return 0;
 }
 
@@ -510,7 +510,7 @@ int unix_fna_network_budget_to_bytes(const frsh_resource_id_t resource_id,
                                      const struct timespec *budget,
                                      size_t *nbytes)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }
 
@@ -522,7 +522,7 @@ int unix_fna_network_budget_to_bytes(const frsh_resource_id_t resource_id,
 int unix_fna_network_get_min_eff_budget(const frsh_resource_id_t resource_id,
                                         struct timespec *budget)
 {
-        DEBUG("NOT IMPLEMENTED\n");
+        DEBUG(DBG_UNIX_FNA_NOT_IMPLEMENTED, "NOT IMPLEMENTED\n");
         return 0;
 }