source: svn/newcon3bcm2_21bu/nexus/lib/ipc/bipc_util.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 4.5 KB
Line 
1/******************************************************************************
2 *    (c)2011 Broadcom Corporation
3 *
4 * This program is the proprietary software of Broadcom Corporation and/or its licensors,
5 * and may only be used, duplicated, modified or distributed pursuant to the terms and
6 * conditions of a separate, written license agreement executed between you and Broadcom
7 * (an "Authorized License").  Except as set forth in an Authorized License, Broadcom grants
8 * no license (express or implied), right to use, or waiver of any kind with respect to the
9 * Software, and Broadcom expressly reserves all rights in and to the Software and all
10 * intellectual property rights therein.  IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU
11 * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY
12 * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE.
13 *
14 * Except as expressly set forth in the Authorized License,
15 *
16 * 1.     This program, including its structure, sequence and organization, constitutes the valuable trade
17 * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof,
18 * and to use this information only in connection with your use of Broadcom integrated circuit products.
19 *
20 * 2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
21 * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
22 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
23 * THE SOFTWARE.  BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES
24 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,
25 * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION
26 * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF
27 * USE OR PERFORMANCE OF THE SOFTWARE.
28 *
29 * 3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS
30 * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR
31 * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR
32 * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT
34 * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
35 * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF
36 * ANY LIMITED REMEDY.
37 *
38 * $brcm_Workfile: bipc_util.c $
39 * $brcm_Revision: 1 $
40 * $brcm_Date: 10/4/11 5:44p $
41 *
42 * Module Description:
43 *
44 * Revision History:
45 *
46 * $brcm_Log: /nexus/lib/ipc/bipc_util.c $
47 *
48 * 1   10/4/11 5:44p vsilyaev
49 * SW7425-1364: Reference applicaion IPC and reference server
50 *
51 *****************************************************************************/
52#include "bstd.h"
53#include "bipc_impl.h"
54#include <unistd.h>
55#include <errno.h>
56
57BDBG_MODULE(bipc_util);
58
59int b_safe_write(int fd, const void *buf, size_t buf_size)
60{
61    int result;
62
63    for(result=0;;) {
64        int rc;
65        if(buf_size==0) {
66            break;
67        }
68        rc = write(fd, buf, buf_size);
69        if(rc>0) {
70            BDBG_ASSERT((unsigned)rc<=buf_size);
71            result += rc;
72            if((unsigned)rc==buf_size) {
73                break;
74            }
75            BDBG_ASSERT((unsigned)rc<=buf_size);
76            buf_size -= rc;
77            buf = (uint8_t *)buf + rc;
78        } else {
79            rc = errno;
80            if(rc==EINTR) {
81                continue;
82            } else if((rc==EAGAIN || rc==EWOULDBLOCK) && result==0) {
83                break;
84            } else {
85                result = -rc;
86                break;
87            }
88        }
89    }
90    return result;
91}
92
93int b_safe_read(int fd, void *buf, size_t buf_size)
94{
95    int result;
96    for(result=0;;) {
97        int rc;
98        if(buf_size==0) {
99            break;
100        }
101        rc = read(fd, buf, buf_size);
102        if(rc>0) {
103            BDBG_ASSERT((unsigned)rc<=buf_size);
104            result += rc;
105            if((unsigned)rc==buf_size) {
106                break;
107            }
108            BDBG_ASSERT((unsigned)rc<=buf_size);
109            buf_size -= rc;
110            buf = (uint8_t *)buf + rc;
111        } else {
112            if(rc==0) {
113                result = -BERR_END_OF_FILE;
114                break;
115            }
116            rc = errno;
117            if(rc==EINTR) {
118                continue;
119            } else if((rc==EAGAIN || rc==EWOULDBLOCK) && result==0) {
120                break;
121            } else {
122                result = -rc;
123                break;
124            }
125        }
126    }
127    return result;
128}
129
130
Note: See TracBrowser for help on using the repository browser.