Commit ddf727a3 authored by Pietro Fezzardi's avatar Pietro Fezzardi Committed by Alessandro Rubini

arch-sim: FIX insert_pending()

parent 61c0b772
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
/* Socket interface for GNU/Linux (and most likely other posix systems) */ /* Socket interface for GNU/Linux (and most likely other posix systems) */
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <sys/socket.h> #include <sys/socket.h>
...@@ -28,7 +29,7 @@ static int compare_pending(struct sim_pending_pkt *p1, ...@@ -28,7 +29,7 @@ static int compare_pending(struct sim_pending_pkt *p1,
if (p1->delay_ns < p2->delay_ns) if (p1->delay_ns < p2->delay_ns)
return 1; return 1;
/* same expire time ---> higher priority to the slave beacuse it has to /* same expire time ---> higher priority to the slave because it has to
* handle Sync and Follow_Up in a row. If both are for the slave handle * handle Sync and Follow_Up in a row. If both are for the slave handle
* PP_NP_EVT first */ * PP_NP_EVT first */
if (p1->delay_ns == p2->delay_ns) { if (p1->delay_ns == p2->delay_ns) {
...@@ -46,15 +47,14 @@ static int insert_pending(struct sim_ppg_arch_data *data, ...@@ -46,15 +47,14 @@ static int insert_pending(struct sim_ppg_arch_data *data,
struct sim_pending_pkt *pkt, tmp; struct sim_pending_pkt *pkt, tmp;
int i = data->n_pending; int i = data->n_pending;
pkt = &data->pending[i]; data->pending[i] = *new;
*pkt = *new; pkt = &data->pending[i - 1];
pkt--;
while (compare_pending(new, pkt) && (i > 0)) { while (compare_pending(new, pkt) && (i > 0)) {
tmp = *pkt; tmp = *pkt;
*pkt = *new; *pkt = *new;
*new = tmp; *(pkt + 1) = tmp;
pkt--; pkt--;
new--; i--;
} }
data->n_pending++; data->n_pending++;
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment