~lttng/lttng-ust/lttng-ust

« back to all changes in this revision

Viewing changes to share/share.h

  • Committer: Pierre-Marc Fournier
  • Date: 2009-10-27 22:58:15 UTC
  • mfrom: (232.1.5)
  • Revision ID: git-v1:aa08b4413291fabcbd1b1144377d37034ad361de
Merge branch 'for-pierre-marc' of git://git.infradead.org/users/jblunck/ust

Fixed conflicts:
        include/ust/marker.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef UST_SHARE_H
2
 
#define UST_SHARE_H
3
 
 
4
 
#include <unistd.h>
5
 
#include <errno.h>
6
 
 
7
 
/* This write is patient because it restarts if it was incomplete.
8
 
 */
9
 
 
10
 
static inline ssize_t patient_write(int fd, const void *buf, size_t count)
11
 
{
12
 
        const char *bufc = (const char *) buf;
13
 
        int result;
14
 
 
15
 
        for(;;) {
16
 
                result = write(fd, bufc, count);
17
 
                if(result == -1 && errno == EINTR) {
18
 
                        continue;
19
 
                }
20
 
                if(result <= 0) {
21
 
                        return result;
22
 
                }
23
 
                count -= result;
24
 
                bufc += result;
25
 
 
26
 
                if(count == 0) {
27
 
                        break;
28
 
                }
29
 
        }
30
 
 
31
 
        return bufc-(const char *)buf;
32
 
}
33
 
 
34
 
#endif /* UST_SHARE_H */