本文整理汇总了C++中pv函数的典型用法代码示例。如果您正苦于以下问题:C++ pv函数的具体用法?C++ pv怎么用?C++ pv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dc_add_altitude
static int dc_add_altitude()
{
HKEY hkey1 = NULL;
HKEY hkey2 = NULL;
int succs = 0;
u32 flags = 0;
if (RegCreateKey(
HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\dcrypt\\Instances", &hkey1) != 0)
{
goto exit;
}
if (RegSetValueEx(hkey1, L"DefaultInstance", 0, REG_SZ, pv(L"dcrypt"), sizeof(L"dcrypt")) != 0) {
goto exit;
}
if (RegCreateKey(hkey1, L"dcrypt", &hkey2) != 0) {
goto exit;
}
if (RegSetValueEx(hkey2, L"Altitude", 0, REG_SZ, pv(L"87150"), sizeof(L"87150")) != 0) {
goto exit;
}
succs = RegSetValueEx(hkey2, L"Flags", 0, REG_DWORD, pv(&flags), sizeof(flags)) == 0;
if (hkey2 != NULL) RegCloseKey(hkey2);
if (hkey1 != NULL) RegCloseKey(hkey1);
exit:
return succs != 0 ? ST_OK : ST_REG_ERROR;
}
示例2: go
inline bool go()
{
k=0;
p[k].resize(0);
p[k].push_back(pv(-inf,inf));
p[k].push_back(pv(-inf,-inf));
p[k].push_back(pv(inf,-inf));
p[k].push_back(pv(inf,inf));
for(i=0;i<n;++i)
{
get(pnt[i],pnt[(i+1)%n],a,b,c);
c+=the*sqrt(a*a+b*b);
p[!k].resize(0);
for(l=0;l<p[k].size();++l)
if(a*p[k][l].x+b*p[k][l].y+c<eps)
p[!k].push_back(p[k][l]);
else
{
m=(l+p[k].size()-1)%p[k].size();
if(a*p[k][m].x+b*p[k][m].y+c<-eps)
p[!k].push_back(ins(p[k][m],p[k][l]));
m=(l+1)%p[k].size();
if(a*p[k][m].x+b*p[k][m].y+c<-eps)
p[!k].push_back(ins(p[k][m],p[k][l]));
}
k=!k;
if(p[k].empty())
break;
}
//`结果在p[k]中`
return p[k].empty();
}
示例3: main
int main(int argc, char *argv[])
{
int sem_id = semget(IPC_PRIVATE, 1, 0666);
union semun sem_un;
sem_un.val = 1;
semctl(sem_id, 0, SETVAL, sem_un);
pid_t pid = fork();
if (pid < 0) {
return 1;
} else if (pid == 0) {
printf("Child try to get binary sem\n");
pv(sem_id, -1);
printf("Child get the sem and would release it after 5 seconds\n");
sleep(5);
pv(sem_id, 1);
exit(0);
} else {
printf("Parent try to get binary sem\n");
pv(sem_id, -1);
printf("Parent get the sem and would release it after 5 seconds\n");
sleep(5);
pv(sem_id, 1);
}
waitpid(pid, NULL, 0);
semctl(sem_id, 0, IPC_RMID, sem_un);
return EXIT_SUCCESS;
}
示例4: dc_is_this_ssd
static int dc_is_this_ssd(dev_hook *hook)
{
STORAGE_PROPERTY_QUERY query = { StorageDeviceSeekPenaltyProperty, PropertyStandardQuery };
DEVICE_SEEK_PENALTY_DESCRIPTOR seek = {0};
char buff[sizeof(ATA_PASS_THROUGH_EX) + sizeof(IDENTIFY_DEVICE_DATA)] = {0};
PATA_PASS_THROUGH_EX pata = pv(buff);
PIDENTIFY_DEVICE_DATA idat = pv(buff + sizeof(ATA_PASS_THROUGH_EX));
int resl;
resl = io_hook_ioctl(hook, IOCTL_STORAGE_QUERY_PROPERTY, &query, sizeof(query), &seek, sizeof(seek));
if ( (resl == ST_OK) && (seek.Version >= sizeof(seek)) && (seek.Size >= sizeof(seek)) ) {
DbgMsg("seek.IncursSeekPenalty %d\n", seek.IncursSeekPenalty);
return seek.IncursSeekPenalty == FALSE;
}
pata->Length = sizeof(ATA_PASS_THROUGH_EX);
pata->DataBufferOffset = sizeof(ATA_PASS_THROUGH_EX);
pata->DataTransferLength = sizeof(IDENTIFY_DEVICE_DATA);
pata->AtaFlags = ATA_FLAGS_DATA_IN;
pata->TimeOutValue = 2;
pata->CurrentTaskFile[6] = IDE_COMMAND_IDENTIFY;
if (io_hook_ioctl(hook, IOCTL_ATA_PASS_THROUGH, buff, sizeof(buff), buff, sizeof(buff)) != ST_OK) {
return 0;
} else {
DbgMsg("idat->NominalMediaRotationRate %d\n", idat->NominalMediaRotationRate);
}
return idat->NominalMediaRotationRate == 1;
}
示例5: leastSquaresEstimate
Vector2d leastSquaresEstimate(vector<Vector2f> points,
Vector2f p0, Vector2f p3,
Vector2d d1, Vector2d d2)
{
// hack up points
if(points.size() <= 10)
points = interpolatePoints(points);
if(points.size() <= 20)
points = interpolatePoints(points);
qDebug() << "num points in arc" << points.size();
int m = points.size()-2; // number of points to fit
int n = 2; // number of control points to find
Eigen::MatrixXd Z(m, n);
Eigen::MatrixXd Y(m, n);
Eigen::VectorXd pu(m);
Eigen::VectorXd pv(m);
for(int i = 0; i < m; ++i)
{
int idx = i+1;
Vector2f pt = points[idx];
double t = double(idx)/(m-1);
auto b0 = Bernstein3(0, t);
auto b1 = Bernstein3(1, t);
auto b2 = Bernstein3(2, t);
auto b3 = Bernstein3(3, t);
// Filling in the matrices
Z(i, 0) = b1*d1[0];
Z(i, 1) = b2*d2[0];
Y(i, 0) = b1*d1[1];
Y(i, 1) = b2*d2[1];
auto pp = pt - p0*(b0 + b1) - p3*(b2 + b3);
pu(i) = pp[0];
pv(i) = pp[1];
}
auto Zt = Z.transpose();
auto Yt = Y.transpose();
auto A = Zt*Z+Yt*Y;
auto rhs = Zt*pu+Yt*pv;
Eigen::VectorXd ans = A.inverse()*rhs;
auto s = makeVector2d(ans(0), ans(1));
qDebug() << "least squares" << s[0] << s[1];
s[0]=fabs(s[0])/**10*/;
s[1]=fabs(s[1]);
return s;
}
示例6: boot_from_mbr
static void boot_from_mbr(hdd_inf *hdd, int n_mount)
{
if ( !(conf.options & OP_EXTERNAL) && (hdd->dos_numb == boot_dsk) ) {
autocpy(pv(0x7C00), conf.save_mbr, SECTOR_SIZE);
} else {
dc_disk_io(hdd, pv(0x7C00), 1, 0, 1);
}
bios_jump_boot(hdd->dos_numb, n_mount);
}
示例7: static_cast_test
void static_cast_test()
{
{
boost::shared_ptr<void> pv;
boost::shared_ptr<int[]> pi = boost::static_pointer_cast<int[]>( pv );
BOOST_TEST( pi.get() == 0 );
boost::shared_ptr<int[3]> pi2 = boost::static_pointer_cast<int[3]>( pv );
BOOST_TEST( pi2.get() == 0 );
boost::shared_ptr<X[]> px = boost::static_pointer_cast<X[]>( pv );
BOOST_TEST( px.get() == 0 );
boost::shared_ptr<X[5]> px2 = boost::static_pointer_cast<X[5]>( pv );
BOOST_TEST( px2.get() == 0 );
}
{
boost::shared_ptr<int[]> pi( new int[2] );
boost::shared_ptr<void> pv( pi );
boost::shared_ptr<int[]> pi2 = boost::static_pointer_cast<int[]>( pv );
BOOST_TEST(pi.get() == pi2.get());
BOOST_TEST(!(pi < pi2 || pi2 < pi));
boost::shared_ptr<int[2]> pi3 = boost::static_pointer_cast<int[2]>( pv );
BOOST_TEST(pi.get() == pi3.get());
BOOST_TEST(!(pi < pi3 || pi3 < pi));
boost::shared_ptr<void> pv2( pi3 );
boost::shared_ptr<int[]> pi4 = boost::static_pointer_cast<int[]>( pv2 );
BOOST_TEST(pi.get() == pi4.get());
BOOST_TEST(!(pi < pi4 || pi4 < pi));
}
{
boost::shared_ptr<X[]> px( new X[4] );
boost::shared_ptr<void> pv( px );
boost::shared_ptr<X[]> px2 = boost::static_pointer_cast<X[]>( pv );
BOOST_TEST(px.get() == px2.get());
BOOST_TEST(!(px < px2 || px2 < px));
boost::shared_ptr<X[4]> px3 = boost::static_pointer_cast<X[4]>( pv );
BOOST_TEST(px.get() == px3.get());
BOOST_TEST(!(px < px3 || px3 < px));
boost::shared_ptr<void> pv2( px3 );
boost::shared_ptr<X[]> px4 = boost::static_pointer_cast<X[]>( pv2 );
BOOST_TEST(px.get() == px4.get());
BOOST_TEST(!(px < px4 || px4 < px));
}
}
示例8: gfs2_rindex_print
void gfs2_rindex_print(const struct gfs2_rindex_host *ri)
{
printk(KERN_INFO " ri_addr = %llu\n", (unsigned long long)ri->ri_addr);
pv(ri, ri_length, "%u");
printk(KERN_INFO " ri_data0 = %llu\n", (unsigned long long)ri->ri_data0);
pv(ri, ri_data, "%u");
pv(ri, ri_bitbytes, "%u");
}
示例9: com_putchar
void com_putchar(char ch)
{
if (ch == '\n') {
com_putchar('\r');
}
while ((READ_PORT_UCHAR (pv(SER_LSR(COM_BASE))) & SR_LSR_TBE) == 0);
WRITE_PORT_UCHAR(pv(SER_THR(COM_BASE)), ch);
}
示例10: dc_backup_header
int dc_backup_header(wchar_t *dev_name, dc_pass *password, void *out)
{
dc_header *header = NULL;
xts_key *hdr_key = NULL;
dev_hook *hook = NULL;
int resl;
s8 salt[PKCS5_SALT_SIZE];
do
{
if ( (hook = dc_find_hook(dev_name)) == NULL ) {
resl = ST_NF_DEVICE; break;
}
wait_object_infinity(&hook->busy_lock);
if (hook->flags & (F_SYNC | F_UNSUPRT | F_DISABLE | F_CDROM)) {
resl = ST_ERROR; break;
}
if ( (hdr_key = mm_alloc(sizeof(xts_key), MEM_SECURE)) == NULL ) {
resl = ST_NOMEM; break;
}
/* get device params */
if (hook->dsk_size == 0) {
if ( (resl = dc_fill_disk_info(hook)) != ST_OK ) break;
}
if ( (resl = io_read_header(hook, &header, NULL, password)) != ST_OK ) {
break;
}
/* generate new salt */
cp_rand_bytes(header->salt, PKCS5_SALT_SIZE);
/* save original salt */
memcpy(salt, header->salt, PKCS5_SALT_SIZE);
/* init new header key */
cp_set_header_key(hdr_key, header->salt, header->alg_1, password);
/* encrypt header with new key */
xts_encrypt(pv(header), pv(header), sizeof(dc_header), 0, hdr_key);
/* restore original salt */
memcpy(header->salt, salt, PKCS5_SALT_SIZE);
/* copy header to output */
memcpy(out, header, sizeof(dc_header));
resl = ST_OK;
} while (0);
if (hook != NULL) {
KeReleaseMutex(&hook->busy_lock, FALSE);
dc_deref_hook(hook);
}
/* prevent leaks */
burn(salt, sizeof(salt));
/* free memory */
if (header != NULL) mm_free(header);
if (hdr_key != NULL) mm_free(hdr_key);
return resl;
}
示例11: sigUser
// ****************************************************************************
void sigUser(int sig) {
if (SIGUSR1 == sig) {
pv("SIGUSR1 received\n");
}
else if (SIGUSR2 == sig) {
pv("SIGUSR2 received\n");
}
else {
err_dump("unkown sig: %d\n", sig);
}
}
示例12: io_write_header
int io_write_header(dev_hook *hook, dc_header *header, xts_key *hdr_key, dc_pass *password)
{
u8 salt[PKCS5_SALT_SIZE];
int hdr_len = max(sizeof(dc_header), hook->bps);
dc_header *hcopy = NULL;
xts_key *h_key = hdr_key;
int resl;
do
{
if ( (hcopy = mm_alloc(hdr_len, MEM_SECURE | MEM_SUCCESS)) == NULL ) { resl = ST_NOMEM; break; }
memcpy(hcopy, header, sizeof(dc_header));
if (h_key == NULL) {
if ( (h_key = mm_alloc(sizeof(xts_key), MEM_SECURE | MEM_SUCCESS)) == NULL ) { resl = ST_NOMEM; break; }
}
if (hdr_key == NULL)
{
/* add volume header to random pool because RNG not
have sufficient entropy at boot time
*/
cp_rand_add_seed(header, sizeof(dc_header));
/* generate new salt */
cp_rand_bytes(salt, PKCS5_SALT_SIZE);
/* copy salt to header */
memcpy(hcopy->salt, salt, PKCS5_SALT_SIZE);
/* init new header key */
cp_set_header_key(h_key, salt, header->alg_1, password);
} else {
/* save original salt */
memcpy(salt, header->salt, PKCS5_SALT_SIZE);
}
/* calc header CRC */
hcopy->hdr_crc = crc32(pv(&hcopy->version), DC_CRC_AREA_SIZE);
/* encrypt header with new key */
xts_encrypt(pv(hcopy), pv(hcopy), sizeof(dc_header), 0, h_key);
/* restore original salt */
memcpy(hcopy->salt, salt, PKCS5_SALT_SIZE);
/* fill the gap with random numbers */
if (hdr_len > sizeof(dc_header)) {
cp_rand_bytes(pv(hcopy + 1), hdr_len - sizeof(dc_header));
}
/* write new header */
resl = io_hook_rw(hook, hcopy, hdr_len, 0, 0);
} while (0);
/* prevent leaks */
burn(salt, sizeof(salt));
/* free resources */
if (h_key != NULL && h_key != hdr_key) mm_free(h_key);
if (hcopy != NULL) mm_free(hcopy);
return resl;
}
示例13: main
int main( int argc, char **argv )
{
int retv = 0 ;
char *p = NULL ;
alloca2_init(1024) ;
pv(p,alloca2_base) ;
pv(p,alloca2_top) ;
pv(p,p) ;
/* grab alloca2's memory until we run out
*/
int n = 0 ;
do {
p = alloca2(100) ;
if( p != NULL )
n++ ;
pv(p,p) ;
} while( p != NULL ) ;
/* we ran out of (alloca2) memory to get here
*
* let's release some back and see what happens
*/
alloca2_release( n * 100 ) ;
do {
p = alloca2(100) ;
if( p != NULL )
n++ ;
pv(p,p) ;
} while( p != NULL ) ;
/* You should see that not all the memory could be
* reused. This is because of alignment issues as
* alloca2 always keeps addresses aligned to
* 16 bytes.
*/
return retv ;
}
示例14: dc_mount_parts
static int dc_mount_parts()
{
dc_header *header = pv(0x5000); /* free memory location */
dc_key *hdr_key = pv(0x5000 + sizeof(dc_header));
list_entry *entry;
prt_inf *prt;
int n_mount;
/* mount partitions on all disks */
n_mount = 0;
entry = prt_head.flink;
while ( (entry != &prt_head) && (n_mount < MAX_MOUNT) )
{
prt = contain_record(entry, prt_inf, entry_glb);
entry = entry->flink;
do
{
/* read volume header */
if (dc_partition_io(prt, header, DC_AREA_SECTORS, 0, 1) == 0) {
break;
}
if (dc_decrypt_header(hdr_key, header, &bd_dat->password) == 0) {
break;
}
if (header->flags & VF_REENCRYPT) {
prt->o_key.key_d = malloc(PKCS_DERIVE_MAX);
autocpy(prt->o_key.key_d, header->key_2, PKCS_DERIVE_MAX);
}
prt->d_key.key_d = malloc(PKCS_DERIVE_MAX);
autocpy(prt->d_key.key_d, header->key_1, PKCS_DERIVE_MAX);
prt->flags = header->flags;
prt->tmp_size = header->tmp_size / SECTOR_SIZE;
prt->stor_off = header->stor_off / SECTOR_SIZE;
prt->disk_id = header->disk_id;
prt->d_key.alg = header->alg_1;
prt->o_key.alg = header->alg_2;
prt->mnt_ok = 1; n_mount++;
} while (0);
}
/* prevent leaks */
zeroauto(header, sizeof(dc_header));
zeroauto(hdr_key, sizeof(dc_key));
return n_mount;
}
示例15: gfs2_sb_print2
/**
* gfs2_sb_print2 - Print out a superblock
* @sb: the cpu-order buffer
*/
static void gfs2_sb_print2(struct gfs2_sb *sbp2)
{
gfs2_meta_header_print(&sbp2->sb_header);
pv(sbp2, sb_fs_format, "%u", "0x%x");
pv(sbp2, sb_multihost_format, "%u", "0x%x");
if (sbd.gfs1)
pv(sbd1, sb_flags, "%u", "0x%x");
pv(sbp2, sb_bsize, "%u", "0x%x");
pv(sbp2, sb_bsize_shift, "%u", "0x%x");
if (sbd.gfs1) {
pv(sbd1, sb_seg_size, "%u", "0x%x");
gfs2_inum_print2("jindex ino", &sbd1->sb_jindex_di);
gfs2_inum_print2("rindex ino", &sbd1->sb_rindex_di);
}
else
gfs2_inum_print2("master dir", &sbp2->sb_master_dir);
gfs2_inum_print2("root dir ", &sbp2->sb_root_dir);
pv(sbp2, sb_lockproto, "%s", NULL);
pv(sbp2, sb_locktable, "%s", NULL);
if (sbd.gfs1) {
gfs2_inum_print2("quota ino ", &gfs1_quota_di);
gfs2_inum_print2("license ", &gfs1_license_di);
}
#ifdef GFS2_HAS_UUID
print_it(" sb_uuid", "%s", NULL, str_uuid(sbp2->sb_uuid));
#endif
}